Jump to content

[SOLVED] i am not sure where the issue is


jeppers

Recommended Posts

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

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.

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

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.