Snoozy Posted April 11, 2011 Share Posted April 11, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/233387-query-problem-slight-php-related/ Share on other sites More sharing options...
Pikachu2000 Posted April 11, 2011 Share Posted April 11, 2011 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(). Quote Link to comment https://forums.phpfreaks.com/topic/233387-query-problem-slight-php-related/#findComment-1200203 Share on other sites More sharing options...
Snoozy Posted April 11, 2011 Author Share Posted April 11, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/233387-query-problem-slight-php-related/#findComment-1200207 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.