View Full Version : my update query isn't working :(
dv6cougar
05-16-2003, 11:30 PM
i'm working on a raffle system and so far so good ;)
however this update statement is not working
$urh = $DB_site->query("UPDATE raffle_images SET comment='$comment' WHERE id='$id'");
i'm echo out $urh afterwards btw and it just returns a 1!!!!
how does that give me one? and it does it for all my images in the database :disappointed:
i tried using different variables for urh, hence why it's urh haha....
but it alwasy gives me 1, which is odd :cross-eyed:
the $id comes from teh title bar, which it is catching correctly i checked.
this is for a script in admin panel btw... my other update portion works fine just like this....
thanks all :banana:
filburt1
05-17-2003, 02:40 AM
Updates never return anything useful beyond success or failure (and on failure the script will die anyway)...what are you trying to do?
dv6cougar
05-17-2003, 03:20 AM
thanks for your reply and it's a field in the database comment that i need to update through a form, here's the entire portion of the script
if($update) {
$urh = $DB_site->query("UPDATE raffle_images SET comment='$comment' WHERE id='$id'");
echo "<center><br><h2>Image Options</h2><br><br>";
echo "Updated your comment to $comment<br>$urh";
} else {
$sele = $DB_site->query("SELECT * FROM raffle_images WHERE id='$id'");
echo "<center><br><h2>Image Options</h2><br><br>";
$seleql = $DB_site->fetch_array($sele);
echo "<form action=\"misc.php?action=imgupd\" method=\"post\">";
echo "<textarea name=\"comment\" rows=10 cols=40>".$seleql['comment']."</textarea><br><br>";
echo "<input type=submit name=\"update\" value=\"Update Comment\"></form>";
}
so upon submit(update in this case) the script will run througha nd update the field, and the if($update) {
is workign as it comes up and gives me that it has been updated, although it has not.
but with what your saying above is true, and it's eitehr gonna go through or have an error, i'm thinking it is throwing an error and that the error is error # 1 whatever that one is.
thanks :)
filburt1
05-17-2003, 01:02 PM
If it fails, the script will die anyway. Your failure code will never execute.
dv6cougar
05-17-2003, 01:41 PM
i'm gonna add or die(""); and see if it is my query, which i'm guessing it must be :)
thanks for your help, hopefully i'll figure it out soon
filburt1
05-17-2003, 02:12 PM
You don't seem to understand. With the MySQL wrapper class that vB uses, it will die by itself if the query fails.
dv6cougar
05-17-2003, 04:50 PM
Today at 04:12 PM filburt1 said this in Post #6 (https://vborg.vbsupport.ru/showthread.php?postid=396162#post396162)
You don't seem to understand. With the MySQL wrapper class that vB uses, it will die by itself if the query fails.
ohhhhh yeah your right i didn't understand...
however I fixed my problem, what I had forgotten to do in the form action was
action="misc.php?action=updimg&id=$id"
so my query couldn't determine the $id variable hence there's nothing to update :)
thanks alot though......
so no matter what query you run in any VB page the query dies if it's failure then? :p
filburt1
05-17-2003, 05:12 PM
As long as you call it via $DB_site->query(), then yes :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.