Jump to content

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

 

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.