If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] PHP's PDO

So as you may know I am creating a multiple database connect and writing to multiple databases using PHP's PDO set. Im rather new to the whole PDO scene so its a learning curve with me. Here is my code, and below are my questions.

//Checks if any feilds were left empty and creates an error message to displayif(empty($first_name)) $ERRmsg .= 'You did not enter a First Name! Pleaase go back and try again! <br/>'; if(empty($last_name)) $ERRmsg .= 'You did not enter a Last Name! Please go back and try again! <br/>'; if(empty($phone_number_1)) $ERRmsg .= 'You did not enter a Phone Number! Please go back and try again! <br/>'; if(empty($address)) $ERRmsg .= 'You did not enter an Address! Please go back and try again! <br/>'; if(empty($state)) $ERRmsg .= 'You did not choose a State! Please go back and try again! <br/>'; if(empty($city)) $ERRmsg .= 'You did not enter a City! Please go back and try again! <br/>'; if(empty($zip_code)) $ERRmsg .= 'You did not enter a Zip Code. Please go back and try again!<br/>'; if(empty($email_1)) $ERRmsg .= 'You did not enter a Email. Please go back and try again!<br/>'; if(empty($email_2)) $ERRmsg .= 'You did not re-enter you Email. Please go back and try again!<br/>'; if(empty($username)) $ERRmsg .= 'You did not enter a Username. Please go back and try again!<br/>'; if(empty($password_1)) $ERRmsg .= 'You did not enter a password! Please go back and try again!<br/>'; if(empty($jed)) $ERRmsg .= 'You did not choose a Jednostka! Please go back and try again!<br/>'; if(empty($dob)) $ERRmsg .= 'You did not enter a Date of Birth! Please go back and try again!<br/>'; if(empty($stopien)) $ERRmsg .= 'You did not choose a Stopien! Please go back and try again!<br/>'; if(empty($funk)) $ERRmsg .= 'You did not enter a Funkcjia! Please go back and try again!<br/>'; if($email_1 !== $email_2) $ERRmsg .= 'Your emails did not match! Please go back and try again!<br/>';

5. The bindParam() method takes care of any quoting and escaping as needed -- one of the benefits of prepared statements with bound input parameters. However, you don't want to make the CONCAT() function a place-holder; instead you want its variable arguments to be place-holders:

Thanks! I concated the names in PHP then binded them. Although I still dont understand the whole ID thing. Since the ID is set to auto-incriment via SQL how do I insert this? just omit it? in the old way you would just leave a space and single quotes. Also I get this error when I try to run this code.

PHP Code:

[24-Nov-2012 16:25:35] array (
0 => 'HY093',
1 => 0,
)

I am gussing that has to do with the whole ID thing.

For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.

Actually I figured out the HY093 error. That was my mistake, by simply trying to input into feilds that I didnt have parameters for. But now a werid issue comes up saying it cannot connect to the Database since no database is selected. Yet when I tested this code prior, just the connect it connected fine. Any thoughts? Here is the revised code.

//Checks if any feilds were left empty and creates an error message to display
if(empty($first_name)) $ERRmsg .= 'You did not enter a First Name! Pleaase go back and try again! <br/>';
if(empty($last_name)) $ERRmsg .= 'You did not enter a Last Name! Please go back and try again! <br/>';
if(empty($phone_number_1)) $ERRmsg .= 'You did not enter a Phone Number! Please go back and try again! <br/>';
if(empty($address)) $ERRmsg .= 'You did not enter an Address! Please go back and try again! <br/>';
if(empty($state)) $ERRmsg .= 'You did not choose a State! Please go back and try again! <br/>';
if(empty($city)) $ERRmsg .= 'You did not enter a City! Please go back and try again! <br/>';
if(empty($zip_code)) $ERRmsg .= 'You did not enter a Zip Code. Please go back and try again!<br/>';
if(empty($email_1)) $ERRmsg .= 'You did not enter a Email. Please go back and try again!<br/>';
if(empty($email_2)) $ERRmsg .= 'You did not re-enter you Email. Please go back and try again!<br/>';
if(empty($username)) $ERRmsg .= 'You did not enter a Username. Please go back and try again!<br/>';
if(empty($password_1)) $ERRmsg .= 'You did not enter a password! Please go back and try again!<br/>';
if(empty($jed)) $ERRmsg .= 'You did not choose a Jednostka! Please go back and try again!<br/>';
if(empty($dob)) $ERRmsg .= 'You did not enter a Date of Birth! Please go back and try again!<br/>';
if(empty($stopien)) $ERRmsg .= 'You did not choose a Stopien! Please go back and try again!<br/>';
if(empty($funk)) $ERRmsg .= 'You did not enter a Funkcjia! Please go back and try again!<br/>';
if($email_1 !== $email_2) $ERRmsg .= 'Your emails did not match! Please go back and try again!<br/>';

Figured out the connection issue, had to change the localhost and dbname. Werid. Anyways, now Im trying to insert the data into the database. It progress fine through the first name, last name and when it gets to the first number it throws out this error.

PHP Code:

array (
0 => '42000',
1 => 1064,
2 => '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 \')

When i look further into this, it omits the last number of the phone number even though the database can accept 12 varchar. (so its 555-555-5555). Why does it throw it out?

For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.