Solved

Problems inserting in to database

Posted on 2013-05-14
2
206 Views
Last Modified: 2013-05-15
$pass = base64_encode($entries[1]);

                        $sql = "INSERT INTO project_domain_list (domain,username,password) VALUES ($entries[0], $pass, $entries[2])";
                        
                        mysql_select_db('inthzcom_intranet');
                        $retval = mysql_query( $sql, $conn );

Open in new window


excerpt from my code, anyway, I'm getting this error:

Could not enter data: 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 ' P~F!~R]?tp)' at line 1

I'm inserting passwords in to the database.  Help?
0
Comment
Question by:nickinthooz
2 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 39166657
Probably needs single quotes for character fields.  Are you sure they're in the right order?

$sql = "INSERT INTO project_domain_list (domain,username,password) VALUES ('$entries[0]', '$pass', '$entries[2]')";

Open in new window

0
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 250 total points
ID: 39166908
Yes you have missed the single quote in your values and again in your values there may be single quote or double quote so you can use addslashes for each values like:

addslashes($pass) = base64_encode($entries[1]);

Open in new window


                       
 $sql = "INSERT INTO project_domain_list (domain,username,password) VALUES ('$entries[0]', '$pass', '$entries[2]')";
                        
                        mysql_select_db('inthzcom_intranet');
                        $retval = mysql_query( $sql, $conn );

Open in new window


If you get extra \ in your string use stripslashes function in string
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 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