Results 1 to 5 of 5


Threaded View

  1. #1
    Join Date
    Jun 2009
    Chi town. IL68 ICAO code home airport, literally.

    resolved [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.
    PHP Code:

    //Create var names
    $first_name $_POST['F_Name'];
    $last_name $_POST['L_Name'];
    $phone_number_1 $_POST['Pnumber1'];
    $phone_number_2 $_POST['Pnumber2'];
    $address $_POST['Address'];
    $state $_POST['State'];
    $city $_POST['City'];
    $zip_code $_POST['Zip'];
    $email_1 $_POST['Email1'];
    $email_2 $_POST['Email2'];
    $username $_POST['Uname'];
    $password_1 $_POST['Pass'];
    $jed $_POST['Jednostka'];
    $dob $_POST['DOB'];
    $stopien $_POST['Stopien'];
    $funk $_POST['FUNK'];
    $hasher = new PasswordHash(8True);
    $password $hasher->HashPassword($password_1);
    $ENC =MD5($password_1);
    $ERRmsg "";

    //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/>';
    $last_name)) $ERRmsg .= 'You did not enter a Last Name!  Please go back and try again! <br/>';
    $phone_number_1)) $ERRmsg .= 'You did not enter a Phone Number!  Please go back and try again! <br/>';
    $address)) $ERRmsg .= 'You did not enter an Address!  Please go back and try again! <br/>';
    $state)) $ERRmsg .= 'You did not choose a State!  Please go back and try again! <br/>';
    $city)) $ERRmsg .= 'You did not enter a City!  Please go back and try again! <br/>';
    $zip_code)) $ERRmsg .= 'You did not enter a Zip Code.  Please go back and try again!<br/>';
    $email_1)) $ERRmsg .= 'You did not enter a Email.  Please go back and try again!<br/>';
    $email_2)) $ERRmsg .= 'You did not re-enter you Email.  Please go back and try again!<br/>';
    $username)) $ERRmsg .= 'You did not enter a Username.  Please go back and try again!<br/>';
    $password_1)) $ERRmsg .= 'You did not enter a password!  Please go back and try again!<br/>';
    $jed)) $ERRmsg .= 'You did not choose a Jednostka!  Please go back and try again!<br/>';
    $dob)) $ERRmsg .= 'You did not enter a Date of Birth!  Please go back and try again!<br/>';
    $stopien)) $ERRmsg .= 'You did not choose a Stopien!  Please go back and try again!<br/>';
    $funk)) $ERRmsg .= 'You did not enter a Funkcjia!  Please go back and try again!<br/>';
    $email_1 !== $email_2$ERRmsg .= 'Your emails did not match!  Please go back and try again!<br/>';
    //Checks to see if error message is empty, if empty does rest of code
                        try {
    $wdp = new PDO('mysql:harcerze_central; host=localhost''harcerze_cuser''Czuwaj_99999');
    "Connected to Warta Database</p>\n";
    //prepare the SQL statement
    $wdp_insert $wdp->prepare
    ("INSERT INTO users( 
                                VALUES (
    $First_name', ' ', '$Last_name'),
    $First_name', ' ', '$Last_name'),
                                    :auto insert,
    //Bind the paramaters
    //Execute the prepared statement
                                    echo (
    "<p>Insert complete</p>\n");
                        } catch (
    PDOException $ex) {
    $msg $ex->errorInfo;
    "<p>Sorry, there was an unrecoverable database error. Debug data has been logged.</p>");
                    else {
                        echo (
    $first_name .' '$ERRmsg);

    So now my questions are as follows:

    1.On the insert I have multiple values, One of them is an ID that has A_I (Auto Incriment) how would I go about leaving that feild blank? The way I did???

    2.I have a feild "Active". That is Automatically 0 untill they confirm their email. Do I simply do :0, or leave that blank?

    3. I have a time stamp that is handeled by the SQL database. So I also leave this blank on the insert?

    4. Im joining two things using a CONCAT, will that work the way i have it set up?

    5. What else do you see that may be incorrect? It seems to me that this DBO way is just easy to inject SQL with. But I think thats just me being used to mysql_real_escape_string.....

    6. And I get an error of "array (0 => 'HY093', 1 => 0,)". Could this be due to the fact of the ID feild?
    Last edited by UAL225; 11-24-2012 at 05:57 PM.
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.48191 seconds
  • Memory Usage 3,440KB
  • Queries Executed 14 (?)
More Information
Template Usage (30):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates