error_22
05-05-2006, 07:33 PM
Hi, I have a problem:
echo "<form action='send.php' method='POST'>";
echo "<select name='pageid'>";
$sql = "SELECT * FROM `page` ORDER by `id`";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<option value='{$row['id']}'>{$row['title']}</option>";
}
echo "</select><input type='submit' value='save'></form>";
in send.php:
$id = $_POST['pageid'];
$sql = "SELECT * FROM `page` WHERE ?id? = '$id'";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ echo "something goes here"; }
I get this when i hit the save button:
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 '?id? = '16'' at line 1
What am i doing wrong?
echo "<form action='send.php' method='POST'>";
echo "<select name='pageid'>";
$sql = "SELECT * FROM `page` ORDER by `id`";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<option value='{$row['id']}'>{$row['title']}</option>";
}
echo "</select><input type='submit' value='save'></form>";
in send.php:
$id = $_POST['pageid'];
$sql = "SELECT * FROM `page` WHERE ?id? = '$id'";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{ echo "something goes here"; }
I get this when i hit the save button:
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 '?id? = '16'' at line 1
What am i doing wrong?