redarrow Posted March 18, 2017 Share Posted March 18, 2017 (edited) 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 March 18, 2017 by redarrow Quote Link to comment https://forums.phpfreaks.com/topic/303484-struggling-with-pdo-and-php/ Share on other sites More sharing options...
benanamen Posted March 18, 2017 Share Posted March 18, 2017 (edited) 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 March 18, 2017 by benanamen 1 Quote Link to comment https://forums.phpfreaks.com/topic/303484-struggling-with-pdo-and-php/#findComment-1544332 Share on other sites More sharing options...
Jacques1 Posted March 18, 2017 Share Posted March 18, 2017 I think “all fail” is a pretty accurate description of the code. 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 1 Quote Link to comment https://forums.phpfreaks.com/topic/303484-struggling-with-pdo-and-php/#findComment-1544333 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.