473,668 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling mysql from PDO returns error unknown field?

228 New Member
I been staring and editing the codes for hours...I cant seem to understand it at all. I want to login basically. I have a mysql stored procedure in this way:

Expand|Select|Wrap|Line Numbers
  1. CREATE DEFINER=`dan78`@`localhost` PROCEDURE `spLogMeIn`(IN uname varchar(12), IN upwd varchar(40))
  2. BEGIN
  3. SELECT memberid,memstatus,mememail,avatarname FROM tblmembers WHERE memuname=uname AND mempwd=upwd;
  4. END
  5.  
PHP: db.php

Expand|Select|Wrap|Line Numbers
  1.   public function runSelectQuery($sql) {
  2.        try {
  3.         $q = $this->conn->prepare($sql);
  4.         $q->execute();
  5.         return $row = $q->fetchAll();
  6.         }
  7.         catch (PDOException $e){
  8.         return $e->getCode();
  9.         }
  10.     }
  11.  
  12.  
and now the login.php

Expand|Select|Wrap|Line Numbers
  1. require(DBFILE);
  2.  
  3. $mydb = new dbACW();
  4. $result = $mydb->runSelectQuery("CALL spLogMeIn($uname,$upwd);");
  5.  
The error code it returns is Unknown field name $username i.e. if i enter samsam for username it would be Unknown fieldname samsam in the fieldlist.

I have other stored procedures that are similar and work awesome. What am i doing wrong?
Dec 28 '14 #1
7 1834
Luuk
1,047 Recognized Expert Top Contributor
quoot: "The error code it returns is Unknown field name $username"

In your code there is no $username..... ?
Dec 28 '14 #2
samvb
228 New Member
dude...$usernam e is just a placeholder. wat ever is in it (e.g if i entere sam as username), error would be "unknown field sam in field list)
Dec 29 '14 #3
Dormilich
8,658 Recognized Expert Moderator Expert
dude...$usernam e is just a placeholder.
that’s your intention but to SQL you indeed give it as field name.
Dec 29 '14 #4
samvb
228 New Member
I think i am not clear...look at the mysql code

SELECT * FROM TBL WHERE FIELDNAME=param eter;

i send parameter from php. but it says parameter is unknown field. parameter is a value to compare against the field FIELDNAME..
Dec 29 '14 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Your stored procedure call doesn't delimit your parameters as strings
Dec 29 '14 #6
samvb
228 New Member
I actually solved after a while...i still dont know why others work but it doesnt. I just declared a variable to store the sql statement, prepare it then execute it.
Dec 30 '14 #7
Dormilich
8,658 Recognized Expert Moderator Expert
you prepare it with the values already in the Statement, so it shouldn’t be called a proper prepared statement.
Dec 30 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2211
by: Marek Baczek Baczyński | last post by:
:map ,p :!python % <cr> ,p #v+ C:\COMMAND.COM /c python items.py Fatal Python error: unknown scope for super in __init__(14) in items.py symbols: {'multirandrange': 264} locals: {} globals: {'multirandrange': True}
6
15579
by: Owen | last post by:
Hi, can somebody help me please... I'm trying to set up a very simple asp page that sends me an email when it runs. This is just to try and get CDOSYS working so I can send out emails from my website. Everything is fine right up until I execute the ".Send" method. What could be wrong? What does the error mean? The output from the source below is: "test1 error '8004020f'
0
3466
by: SiRkNiGhT115 | last post by:
Hello, I am new to MS Access and I am trying to do a database for work just for a school project. I am trying to step up a database for our inventory but I am trying to setup a employee Id box so when you type your name it will enter it in the employee table and in the form, but I keep getting a error saying "Control can't be edited; it's bound to unknown field 'EmployeeID' " could someone help me fix this? I don't really understand what I...
2
7430
by: Fusion | last post by:
Okay, when ever (on Invision Power Board's PM option) we try to send a PM to any other member on the forum, we all get this message... mySQL query error: SELECT m.mgroup_others, m.id, m.name, m.members_disable_pm, m.members_display_name, m.msg_total, m.view_pop, m.email_pm, m.language, m.email, me.vdirs, g.g_max_messages, g.g_use_pm FROM bpass_members m, bpass_groups g LEFT JOIN bpass_member_extra me ON (m.id=me.id) WHERE...
3
3077
by: Gilles Ganault | last post by:
Hello A friend of mine is running a site that has about 1,000 concurrent users when it's really busy. Until now, he kept data in sessions (including output from SELECT fetched from a remote MySQL server), but since most data is the same across users, he tried MemCacheD... but performance is worse than calling MySQL again and again and using a lot of RAM to keep this into sessions. Do you know of other ways to share data across users?...
3
4918
nomad
by: nomad | last post by:
Hello everyone: I new to PHP and I'm reading a book on PHP Bibles 2nd edition. It has to deal with a user-rating system. There are 4 scripts to it. I'm getting an error Unknown column 'quotation' in 'field list' Here is my code rated_display.php <?php
3
4054
by: Ananthu | last post by:
Hi, I use BulkSMSGateway - ATSMS.dll for sending SMS from ASP.NET. When I click Connect button, I am able to connect to the mobile using bluetooth successfully from my WebPage. But when i click Send button, the oGsmModem returns error e.errorcode=4006 in the oGsmModem_OutboxSMSSent event. But i can send SMS successfully using VB.NET Windows Appication.
1
4261
by: Bernard Cunanan | last post by:
Query failed with error: Unknown column 'bernard' in 'where clause' <?php session_start(); ob_start(); $host="localhost"; $user="bernard"; $pass="bernard"; $dbase="myproj"; mysql_connect($host,$user,$pass);
3
1586
sbouley7
by: sbouley7 | last post by:
I've been working with VBA in Access for a while and with the help of Google can figure out most things on my own but this one has got me stumped. I've created running totals in the past with no problem but keep getting #Error in the main form total field. I'm sure it's something really simple but have been working for two days. Thanks in advance!!! Here's what I have: I have a main form with a sub-form in datasheet view. The...
1
3028
by: pavan52 | last post by:
0 down vote favorite hello I am new in magento. I have Uploaded The Magento Script on my domain... But when i was making changes through admin panel.. My Site Stopped Working.. and when i checked the error log report i am getting the following error message PHP Fatal error: Unknown: Failed opening required '/home/happydays/public_html/index.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in Unknown on line 0 I haven't made...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8799
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8586
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.