Jump to content

Going crazy with this


sylvesterfaro

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/139894-going-crazy-with-this/
Share on other sites

$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...

 

 

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!!!!

 

 

 

 

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.