Jump to content

Archived

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

Mutley

Update query appears fine but doesn't work

Recommended Posts

The problem I'm having is it isn't updating the database, I echod the SQL and it looks fine, yet it isn't working.

Here is the code:

[code]<?php
$userid = $_GET['user'];
$page_id = $_GET['page_id'];

require_once("sec_con.php");

if(isset($userid)){
$title = $_POST['title'];
$row['page_id'] = $_POST['page_id'];
$row['description'] = $_POST['description'];
$row['content'] = $_POST['content'];

mysql_select_db("style");

$sql = "UPDATE pages
SET title='$title',
  page_id='$page_id',
  description='$description',
    content='$content',
  WHERE user_id = '".$userid."', page_id = '".$page_id."' LIMIT 1";
mysql_query($sql);
echo $sql;
  echo "The selected information was updated! ";
  echo "<a href='secure/style.php?user=$userid'>Click here</a> to continue editing, or <a href='./index.php?user=$userid'>click here</a> to go back to your website.";
}
?>[/code]

Share this post


Link to post
Share on other sites
I ran the query in phpmyadmin, it said theirs an error in my SQL syntax on/near this line:
[code=php:0]   WHERE user_id = '".$userid."', page_id = '".$page_id."' LIMIT 1";[/code]

Share this post


Link to post
Share on other sites
This line...

[code]   WHERE user_id = '".$userid."', page_id = '".$page_id."' LIMIT 1";
----------------------------------------^[/code]

remove the * , *!

[code]   WHERE user_id = '".$userid."' AND page_id = '".$page_id."' LIMIT 1";


[/code]


me!

Share this post


Link to post
Share on other sites
change the query to this....


[code]$sql = "UPDATE pages SET title = '" . $title . "', page_id = '" . $page_id . "', description = '" . $description . "', content = '" . $content . "' WHERE user_id = '" . $userid . "' AND page_id = '" . $page_id . "' LIMIT 1";[/code]


me!

Share this post


Link to post
Share on other sites

×

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.