Solved

Problems inserting in to database

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

815 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