MYSql insert issue after php upgrade.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rmurdo
Forum Newbie
Posts: 5
Joined: Wed Mar 03, 2004 2:03 am

MYSql insert issue after php upgrade.

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Post code too...
rmurdo
Forum Newbie
Posts: 5
Joined: Wed Mar 03, 2004 2:03 am

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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());
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply