jeppers Posted January 2, 2009 Share Posted January 2, 2009 i am working on a script where a user can edit information on there menu. this is how it works. they log in and are able to view there menu with a edit button next to every item in there menu. they click and it moved to the edit page. hear is my problem i am trying to gather the info mation from the item they have chosen using the $id as a key so the info can be pulled out. this is my problem i can't seem to get the query correct. could you have a look and see if you can spot what i am missing //retrive the users information <?php $query = "SELECT food_id, title, description, price FROM foods WHERE food_id=$id"; $result = @mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) == 1){//valid id show form //get the users information $row = mysql_fetch_array($result, MYSQL_NUM); //create the form echo '<h2> Edit Food. <form action="edit_food.php" method="post"> <p>Title: <input type="text" name="title" size="20" maxlength="20" value="'. $row[0] .'" /></p> <p>Description: <input type="text" name="description" size="15" maxlength="30" value="' . $row[1] . '" /></p> <p>Price: <input type="text" name="price" size="20" maxlength="40" value="' . $row[2] . '" /> </p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; this is the error message 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 thanks for any help Link to comment https://forums.phpfreaks.com/topic/139180-solved-i-am-not-sure-where-the-issue-is/ Share on other sites More sharing options...
ratcateme Posted January 2, 2009 Share Posted January 2, 2009 looks like the mysql server you are connecting to is a higher version than your mysql extension that is installed on php if you create a page with <?php phpinfo(); ?> and find the mysql header there should be a value "Client API version" check that version ageist the version of your mysql server to get that enter "mysql --version" in command line on your server Scott. Link to comment https://forums.phpfreaks.com/topic/139180-solved-i-am-not-sure-where-the-issue-is/#findComment-727956 Share on other sites More sharing options...
jeppers Posted January 2, 2009 Author Share Posted January 2, 2009 well i did the phpifo(); and i got 5.0.45 i then tried finding my mysql version but i just could not find it what do u think i should do. reverting back to my code if that's not the issue. i tried the query in command line and it worked if i put the id number in. so i see the problem being because it does not seem to want to pull the info out as a varable. what do u think the issue could be Link to comment https://forums.phpfreaks.com/topic/139180-solved-i-am-not-sure-where-the-issue-is/#findComment-727959 Share on other sites More sharing options...
ratcateme Posted January 2, 2009 Share Posted January 2, 2009 i am sure it should be the versions how did u access the mysql command line? i can run mysql --version on both my linux and windows servers so i can't see why you shouldn't be able to get you version number Scott. Link to comment https://forums.phpfreaks.com/topic/139180-solved-i-am-not-sure-where-the-issue-is/#findComment-727965 Share on other sites More sharing options...
jeppers Posted January 2, 2009 Author Share Posted January 2, 2009 just not sure what you mean i am running apachi mysql. i have opened up the command line for mysql entered mysql --version just comes up with and error. how do u access apachi command line if i need to Link to comment https://forums.phpfreaks.com/topic/139180-solved-i-am-not-sure-where-the-issue-is/#findComment-727971 Share on other sites More sharing options...
jeppers Posted January 2, 2009 Author Share Posted January 2, 2009 and my mysql server is 5.0 so i am installing the new version which is 5.1.30 i will get back to if no change Link to comment https://forums.phpfreaks.com/topic/139180-solved-i-am-not-sure-where-the-issue-is/#findComment-727988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.