473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Odd Mysql 5 error with php 5

Ajm113
161 100+
I am having some problems with mysql 5. I am trying to update a row, but it seems I get that

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm A Message' at line 1

It seems to do with the description variable's value. Since it has the " ' " in the text, but I thought mysql_esacpe_string would fix this problem. So what do I have to do?

Here is my code:

[PHP]$description2 = htmlentities(stripslashes(mysql_escape_string($_PO ST['description'])));

mysql_query("UPDATE sites SET url='$url2', title='$title2', description='$description2', ad='$ad1', avatar='$avatar' WHERE id = '$site'") or die('<br>'. mysql_error());
[/PHP]

Is this something with my hosting company or did they change some stuff with php5 with mysql_escape_string?
Feb 1 '08 #1
1 1135
ifedi
60
I am having some problems with mysql 5. I am trying to update a row, but it seems I get that

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm A Message' at line 1

It seems to do with the description variable's value. Since it has the " ' " in the text, but I thought mysql_esacpe_string would fix this problem. So what do I have to do?

Here is my code:

[PHP]$description2 = htmlentities(stripslashes(mysql_escape_string($_PO ST['description'])));

mysql_query("UPDATE sites SET url='$url2', title='$title2', description='$description2', ad='$ad1', avatar='$avatar' WHERE id = '$site'") or die('<br>'. mysql_error());
[/PHP]

Is this something with my hosting company or did they change some stuff with php5 with mysql_escape_string?
What is the purpose of using stripslashes() on a string you've already applied mysql_escape_string() to? As far as I know, mysql_escape_string (which actually is deprecated and should be replaced with mysql_real_escape_string) applies escapes to your form data, to make them suitable for entry into the database. Addslashes is an alternative. On the other hand, stripslashes removes these escapes, and the purpose should be to achieve the opposite: make escaped database data suitable for general use (e.g. outputting to browser).
In conclusion, try removing the stripslashes from your code, like so:

[PHP]$description2 = htmlentities(mysql_real_escape_string($_POST['description']));
[/PHP]
... and let's see what happens. Please give a feedback on this.

Regards,
Ifedi.
Feb 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Cathy Hui | last post by:
Do u know why do i get the following message when trying to build the MySql-Python (1.2.0) on my Solaris 8 system? (with mysql 4.0.21 and python 2.4). thanks! error mesg: ld: fatal:...
0
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary...
0
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
0
by: Dennis Francis B. Tutanes | last post by:
$B$*@$OC$K$J$C$F$*$j$^$9!#(B $B%D%?%M%9(B@TSTI$B$G$9!#(B SEND-PR: -*- send-pr -*- SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as SEND-PR: will all comments (text...
4
by: Adam Smith | last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting site. They have done some default installations, presumably from the CVS ports package ??. Herein lies the problem, "I do not...
3
by: Pugi! | last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get the following problem when connecting to mysql through a browser (phpMyAdmin): : #2002 Can't connect to local MySQL...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
8
by: sundeep.kumara | last post by:
hi all, I am a newbie .....I have compiled the source code of mysql-4.1.9 on PPC-Linux Its not giving any errors during configure,make or make install. But,when i try to start the server...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.