473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calling mysql from PDO returns error unknown field?

228 100+
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 1821
Luuk
1,047 Expert 1GB
quoot: "The error code it returns is Unknown field name $username"

In your code there is no $username..... ?
Dec 28 '14 #2
samvb
228 100+
dude...$username 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 Expert Mod 8TB
dude...$username is just a placeholder.
that’s your intention but to SQL you indeed give it as field name.
Dec 29 '14 #4
samvb
228 100+
I think i am not clear...look at the mysql code

SELECT * FROM TBL WHERE FIELDNAME=parameter;

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 Expert Mod 8TB
Your stored procedure call doesn't delimit your parameters as strings
Dec 29 '14 #6
samvb
228 100+
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 Expert Mod 8TB
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
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:...
6
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...
0
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...
2
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,...
3
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...
3
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...
3
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...
1
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";...
3
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...
1
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.