Welcome! Log In Create A New Profile

Advanced

Strange SQL response

Posted by 77928490 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Strange SQL response
May 03, 2013 02:06PM
Hi,

Strange thing is happening. A SQL statement that worked before is providing a 'true' response irrespective now. Weird.

SQL = SELECT * FROM student WHERE sname='Surname' AND fname='First Name' AND email='email@email.com'

Language: PHP
$SQL="SELECT * FROM student WHERE sname=';".$form_value[1]."'; AND fname=';".$form_value[3]."'; AND email=';".$form_value[14]."';";   $result=mysql_query($SQL) or die(mysql_error());   if($result) {//student exists } else {//new student }

So the code above returns true no matter if the values exist or not.

I even deleted the 'student' table and reloaded it incase it became corrupt. Did not work.

Any ideas from your side would be very helpful.

Thanks
Ian
avatar
Mac
Re: Strange SQL response
May 03, 2013 03:02PM
IN a rush here... add a num_rows line and echo it out. If it is empty but there is rows, then check the db field types.
Re: Strange SQL response
May 03, 2013 03:09PM
they to echo $form_value[1] , $form_value[3], $form_value[14] and see what you get
Re: Strange SQL response
May 03, 2013 03:32PM
agh its a Friday - I meant try to echo...
Re: Strange SQL response
May 03, 2013 04:04PM
Hi there,

I followed everyone's suggestions but still could not find the problem.

So instead I will work around the issue and do what Mac suggested, i.e. use numrows as a search criteria.

Thanks again.

Ian
Re: Strange SQL response
May 06, 2013 08:01AM
echo statement was not supposed to solve a problem, but it just shows what values ou are sending to your SQL statement. if you are getting bad values or no values, than you know where your problem is...
Sorry, only registered users may post in this forum.

Click here to login