Solved

i got a an error when i am trying to insert something into mysql using php

Posted on 2008-06-10
6
199 Views
Last Modified: 2008-06-10
this is the error

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 's Day','Valentine's Day','Favorite holiday?','other')' at line 1


what is that?
0
Comment
Question by:mgtm3
6 Comments
 
LVL 9

Accepted Solution

by:
michofreiha earned 167 total points
Comment Utility
Use \ before the single quote

'Valentine\'s Day'
0
 
LVL 28

Expert Comment

by:gamebits
Comment Utility
Not seeing the whole query it's hard to say but my guess is you are not ecaping the ' in 'Valentine's Day' try it with 'Valentine\'s Day' and any other one like that.
0
 

Author Comment

by:mgtm3
Comment Utility
is there no other whay
because i am getting this from a text field and then i am using post action to get it
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 9

Expert Comment

by:michofreiha
Comment Utility
I don't think so...
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 167 total points
Comment Utility
Use mysql_real_escape_string function

http://ca3.php.net/mysql_real_escape_string
0
 
LVL 4

Assisted Solution

by:afzz
afzz earned 166 total points
Comment Utility
Use the insert query as follows:
addslashes will add / to any posted values containing quotes

similarly you can use stripslashes($var) to remove the slashes added above

HTH,
AK
foreach($_POST as $key => $val){

$_POST[$key] = addslashes($val);

}

insert into table values('.$_POST['str1'].','.$_POST['str1'].','....and so on...','.$_POST['last'].');

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now