Page 1 of 1

query problem

Posted: Thu Sep 14, 2006 9:42 pm
by abzu
I have written this script using dreamweaver and my own novice knowledge of PHP. Between the two I have managed to cobble something together that actually does what I want it to do. It may not be the prettiest thing in the world and I am sure there are easier ways to accomplish what I have done, but it works...almost.

I have tested every step right up to the very end and I can echo the correct values onto the screen up to the last part where I try to push some of those values to my database. The problem seems to be with the one line where I construct my update query. If I remove that one line everything else up to that point works great. With it therre I get nothing, not even an error.

here is the section where I think the problem is. Can someone take a look?

this is at the top of the script and is being used successfully to make connections in other places

Code: Select all

<?php  require_once('Connections/anthill.php');
Then at the end I have what I think is my problem section

Code: Select all

$newsubstring =$newsubstring.$antrec;
$thisid = $row_userset['ID'];
mysql_select_db($database_anthill, $anthill);
$query_subst = sprintf("UPDATE users SET subs='%s' WHERE ID='%s'",
   mysql_real_escape_string($newsubstring),
   mysql_real_escape_string($thisid));
   $subsreplace = mysql_query($query_subst, $anthill) or die(mysql_error());
If there doesn't seem to be an obvious proble here then I can post the whole script to see if it is coming from somewhere earlier (I am hoping not since everthing else is working and I don't want to mess with it any more)

Your help is much appreciated

Posted: Thu Sep 14, 2006 9:56 pm
by Zoxive
You dont acually state what the problem/error is, all you do is say there is one...

But what happens when you print the SQL Query? $query_subst ?

I usually for testing purposes put

Code: Select all

or die('Query failed: ' . mysql_error() . '<br>Query: <br>' . $sql);
To see what my built query looks like.

-NSF

Posted: Fri Sep 15, 2006 12:55 pm
by abzu
Thank you so much. I did what you suggested and it showed me that the variable passing the value to SET was coming up empty. With that knowledge I followed the code and found the problem. Works great now.

Thanks again!