sylvesterfaro Posted January 7, 2009 Share Posted January 7, 2009 I think the code is ok, but mysql_query() just doesn't update my database... The code: $link = mysql_connect('localhost', [user], [passowrd]); if (!$link) { die('Could not connect: ' . mysql_error()); } $email="sample"; $frasesql="UPDATE mailing SET invalido=1 where email=TRIM('$email')"; $result = mysql_query($frasesql, $link); echo "Result: ".$result.'<br />'; echo "Affected Rows: ".mysql_affected_rows($link).'<br />'; echo "SQL Sentence: ".$frasesql.'<br />'; NOTE: "sample" DOES exist on table mailing; Now... the output Result: 1 Affected Rows: 0 SQL Sentece: UPDATE mailing SET invalido=1 where email=TRIM('sample ') And the crazy thing: The row is not updated!!! If I paste the SQL Sentece output into MySQL Query Browser... the row gets updated!!! What I'm I doing wrong????? Thanks for any help... I'm getting crazy on this Quote Link to comment https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/ Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 Your not doing a mysql_select_db in that code after the connect.... Quote Link to comment https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/#findComment-731915 Share on other sites More sharing options...
sylvesterfaro Posted January 7, 2009 Author Share Posted January 7, 2009 Your not doing a mysql_select_db in that code after the connect.... I did that... problem not solved Also notice that mysql does not return any errors... Quote Link to comment https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/#findComment-731923 Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 $result = mysql_query($frasesql, $link) or die(mysql_error()); It will if you add that line I bet. Quote Link to comment https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/#findComment-731934 Share on other sites More sharing options...
sylvesterfaro Posted January 7, 2009 Author Share Posted January 7, 2009 $result = mysql_query($frasesql, $link) or die(mysql_error()); It will if you add that line I bet. Nope... As I stated before, result returns 1 - it means the sql executed ok. mysql_error() returns blank Program didn't "die", it continued normaly... Next tip, please... Quote Link to comment https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/#findComment-731940 Share on other sites More sharing options...
sylvesterfaro Posted January 7, 2009 Author Share Posted January 7, 2009 Aaaaaaaaaaaaaaaaaaaaargh Found it!!!!! where I placed $email='sample', in the real code I was getting the email from somewhere... This was missing!!! $email=strip_tags($email); God damn "invisible characters"!!! Thanks everyone for their tips... but it was just me being dumb!!!! Quote Link to comment https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/#findComment-731963 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.