Solved

Problems inserting in to database

Posted on 2013-05-14
2
203 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i gnupg encrypt a PDF document? 12 61
Email called spam 5 36
Wordpress Only run code if on a certain page 11 22
Checking https returns 301 21 17
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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

839 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