Solved

Problems inserting in to database

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

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

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

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 …
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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 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 …

708 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

11 Experts available now in Live!

Get 1:1 Help Now