Jump to content

query problem (slight php related)


Snoozy

Recommended Posts

Hey guys for some reason my script is being strange.

 

<?
if(!empty($_POST['why']))
   {
   $why = mysql_real_escape_string($_POST['why']);
   $answer = $_POST['answer'];
   $id = $_POST['cid'];
   if($answer == "Accept")
   {
	   $query1 = mysql_query("UPDATE characters SET accepted = '1' WHERE id = '".$id."'");
	   $aquery = mysql_query("UPDATE applications SET tester = '".$_COOKIE['Username']."', accepted = '1', answered = '1' WHERE cid = '".$id."'") or die('Could not connect: ' . mysql_error());
	   echo"Successfully accepted";
   }
}

If you notice the echo it outputs the successfully executed, tho the mysql query doesn't go through for some strange issue even through it says it does since I got the or die(mysql_error) thing and it still doesn't output a error. So I got a hard time finding the problem.

Link to comment
https://forums.phpfreaks.com/topic/233387-query-problem-slight-php-related/
Share on other sites

An UPDATE or INSERT query can execute successfully without changing anything in the table. You should be using mysql_affected_rows to see if anything was updated. You're also only checking one of the query executions for errors with mysql_error().

Yea I know but that's cause since the one didn't change and I went into the mysql db with heidisql to check and saw that the other query didn't change either then I was like oh well I'll just check one, the output of the mysql_affect_rows() is: Updated applications0

 

It just struck my mind that, is it possible that this is caused by the WHERE cid = '' ?

 

EDIT: Yea that was the problem haha strange I didn't notice but oh well it's fixed now :)

Archived

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

×
×
  • Create New...

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.