Jump to content


Photo

punctuation problem with MySQL query


  • Please log in to reply
2 replies to this topic

#1 drew69

drew69
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 04 November 2003 - 04:52 PM

Why do I keep getting this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home.......

I have tried surrounding the variables with nothing, \'\" & & \"\', \'& &\', \' \', etc.....


<?
$stryes=\"yes\";
$strwaitno=\"no\";
$sqlind = mysql_query(\"SELECT * FROM resevents WHERE eventnum=\'& $eventnumqs &\' AND show= \'& $stryes &\' AND waitlisted= \'& $strwaitno &\' ORDER BY memlastname\",$dbh);
$rs=mysql_fetch_array($sqlind);
?>

any help would be appreciated!

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 04 November 2003 - 08:38 PM

This should work

[php:1:e0b3a37a3c]<?php
$stryes=\"yes\";
$strwaitno=\"no\";

$sqlind = mysql_query(\"SELECT * FROM resevents WHERE eventnum=$eventnumqs AND show= \'$stryes\' AND waitlisted= \'$strwaitno\' ORDER BY memlastname\",$dbh);

$rs=mysql_fetch_array($sqlind);
?>[/php:1:e0b3a37a3c]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 drew69

drew69
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 04 November 2003 - 10:16 PM

I appreciate the help, I just got it running not too long ago.

Oddly enough, it was having a field named \"show\" that screwed it all up. It thought I was trying to put in another command when it got to that field name.

Weird. It worked under ASP with the field \"show\", but not PHP....

Thanks again




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users