Jump to content

HTML to PHP


sylesia

Recommended Posts

Ok, so I am working on code and currently have it in a .html file, and includes some php that accessess a database.  Unfortunately I need to really add some fun here with if else statements and such that extend thru the html and incorporate them in.  In another words, I need to change my .html to .php but it seems to have issues.  I have no problem running it as .html, works fine, accesses the DB, and everything, but when I simply change it to .php, I start to get errors, including

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\srh\Junk\cadetyellowedit.php on line 63

61 $request = "SELECT $try FROM yellowcard WHERE UserName = '$userName' AND CardNumber = $cardNumber";
62 $eval = mysql_query($request, $conn);
63 while($row = mysql_fetch_assoc($eval)){
64 $$try = $row[$try]."\n";
65 }

any ideas why it will not work as .php but does as .html
Link to comment
https://forums.phpfreaks.com/topic/29595-html-to-php/
Share on other sites

The thing I cannot figure out is why its not working.  It works fine if the file has a .html extension, works perfectly, but as soon as I change it to .php and no other changes, than it comes with that error.  If I add in the or die statement, I get
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Again, that only occurs if it is a .php and not .html extension
Link to comment
https://forums.phpfreaks.com/topic/29595-html-to-php/#findComment-135953
Share on other sites

that is saying that your are checking for a blank variable. try checking $userName has anything and... oh!

change:
[code=php:0]$request = "SELECT $try FROM yellowcard WHERE UserName = '$userName' AND CardNumber = $cardNumber";[/code]

to:
[code=php:0]$request = "SELECT $try FROM `yellowcard` WHERE `UserName`= '$userName' AND `CardNumber`='$cardNumber'";[/code]

notice how i added the ' and ' around $cardNumber. but also check if both variables contain data.
Link to comment
https://forums.phpfreaks.com/topic/29595-html-to-php/#findComment-135975
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.