Page 1 of 1

Simple Problem I'm Sure - Dead Stuck and Deadline SOON

Posted: Wed Jan 28, 2009 12:41 pm
by babinm
Here is my code:

if($targets=="")
{
echo "targets is empty. ";
$query="";

$targets="content.php?page_id=".$_SESSION['article_ID'];
echo "<br />target is: ".$targets;

$sql_update="UPDATE items SET target='".$targets."' WHERE item_ID=".$_SESSION['article_ID'];

echo $sql_update;

$query=mysql_query($sql_update)or die(mysql_error());

echo $query;
}


The output i'm being presented with (due to my echo's to find the error) is:

targets is empty
target is: content.php?page_id=14
UPDATE items SET target='content.php?page_id=14' WHERE item_ID=14
1
__________________________
Nothing runs after this. No error is produced. It is not updating my table. I can't understand it. If i run the query manually through database and copy and paste the SQL it runs fine, but through PHP it's not working. HELP...

Re: Simple Problem I'm Sure - Dead Stuck and Deadline SOON

Posted: Wed Jan 28, 2009 2:41 pm
by Reviresco
Perhaps this might do it:

Code: Select all

 
 
$id = $_SESSION['article_ID'];
 
$sql_update="UPDATE items SET target='$targets' WHERE item_ID='$id' ";
 
 

Re: Simple Problem I'm Sure - Dead Stuck and Deadline SOON

Posted: Wed Jan 28, 2009 3:12 pm
by califdon
Since your variables seem to have the values you intend and there are no errors, I would assume the issue is that the update you requested cannot be performed. For example, if no record matches the WHERE clause. You say that the query does work when you run it manually (how? phpMyAdmin?). I think I would substitute a SELECT query temporarily for your UPDATE query, to make sure that there really is a record and that it has all the fields that you name.