Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problems inserting in to database

Posted on 2013-05-14
2
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 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 1000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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…
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 …
Suggested Courses

604 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