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
MYSql insert issue after php upgrade.
Moderator: General Moderators
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
$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
next time, use a better method of error reporting.
this is a better method to get an EXACT mysql error if one happens...
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());- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Also make sure you echo out the SQL statement with the error -
Mac
Code: Select all
$result = mysql_query($query) or die(mysql_error().'<p>'.$query.'</p>');