Page 1 of 1

MYSql insert issue after php upgrade.

Posted: Wed Mar 03, 2004 2:03 am
by rmurdo
Good morning!

I just upgraded my php to 4.3.4. Now I have a problem.

I have a form that I enter in news articles with quotes and all that. It was working fine and dandy until I upgraded my php.

Now I get a insert error when I try to do this.

I removed all the quotes and other special chars and plain text works fine. I can also urlencode it and again it works fine.

I am thinking a setting I had in php.ini or on the webserver was re-wrote. Any one have an ideas on how to get it working the way it was?

Thanks!!

Rob

Posted: Wed Mar 03, 2004 2:04 am
by markl999
Now I get a insert error when I try to do this.
What is the error? And what's the line that's causing it?

Posted: Wed Mar 03, 2004 2:17 am
by m3mn0n
Post code too...

Posted: Wed Mar 03, 2004 2:24 am
by rmurdo
Code:
$query = "Insert into articles (username, title, source, summary, details, date)
values ('$cusername', '$title', '$source', '$summary', '$detail', '$cccdate')";

$result = mysql_query($query) or die("ERROR while adding records to database [bfw]");

Error is on the result line. I added this line above it:
$detail = mysql_escape_string("$detail");

And it cleared the error. I am assuming I had the magic_quotes in my php.ini to ON ..

I think this is an OK solution, I hope that there are no other problems I am not foreseeing..

Thanks.
ROb

Posted: Wed Mar 03, 2004 2:55 am
by infolock
next time, use a better method of error reporting.

this is a better method to get an EXACT mysql error if one happens...

Code: Select all

$result = mysql_query($query) or die(MySQL_Error());

Posted: Wed Mar 03, 2004 4:09 am
by twigletmac
Also make sure you echo out the SQL statement with the error -

Code: Select all

$result = mysql_query($query) or die(mysql_error().'<p>'.$query.'</p>');
Mac