Jump to content
Sign in to follow this  
redarrow

struggling with pdo and php

Recommended Posts


my code not working it like the $sql->bindParam all fail please help


$user_paypal_email=$_POST['user_paypal_email'];
$user_skype_name=$_POST['user_skype_name'];
$user_package_type=$_POST['user_package_type'];

if( ($user_date_added) && ($user_id) && ($user_paypal_email) && ($user_skype_name) && ($user_package_type) ){

$conn = new PDO("mysql:host=$dbhost; dbname=$dbname", $dbusername, $dbpassword);

$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sql = ("INSERT INTO user_add (`user_id`, `user_paypal_email` , `user_skype_name` , `user_package_type` , `user_date_added` )
VALUES (:user_id, :user_paypal_email, :user_skype_name, :user_package_type, :user_date_added )");

$sql->bindParam(':user_id', $user_id, PDO::PARAM_STR);
$sql->bindParam(':user_paypal_email', $user_paypal_email, PDO::PARAM_STR);
$sql->bindParam(':user_skype_name', $user_skype_name, PDO::PARAM_STR);
$sql->bindParam(':user_package_type', $user_package_type, PDO::PARAM_STR);
$sql->bindParam(':user_date_added', $user_date_added, PDO::PARAM_STR);
$sql->exec($sql);


 

Edited by redarrow

Share this post


Link to post
Share on other sites

my code not working...please help

 

That is the WORST way to ask for help. You have over 7 thousand posts and don't know how make a proper request for help?

 

WHAT isn't working? What is the error message you get? What is the result? Is the missing brace actually in your code and you didn't post it here?

Edited by benanamen
  • Like 1

Share this post


Link to post
Share on other sites

I think “all fail” is a pretty accurate description of the code. :happy-04:

 

redarrow: Take a deep breath, try to concentrate for a few minutes and then do this step by step. You need to

  • Create a prepared statement with $conn->prepare()
  • Bind values to that prepared statement
  • Execute the prepared statement
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.