Results 1 to 7 of 7
  1. #1

    Default Invalid parameter number: no parameters were bound in C: ...etc (PHP)


    Mga master....Naa koy gihimo na social networking site, nya ako rah pud usa gahimo ani(kafaet oi).....mao ni final sah akong elective php karn na summer.....Naa nakoy nahimo na code na mo gana jud pero taas2x to ("dli PDO akong gamit") na inig login sa user, ma retrieve ang rows/data gikan sah akong sql para i display niya ang bio sah user

    Karun nag testing ko ug lain, PDO akong g gamit sulod sa akong function para ma retrieve nako ang basic info sa user.
    Ang error kay:

    Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in C:\wamp\www\IT322_Finals\connectDB.php on line 77

    Akong g suwayan ug retrieve ani kay ang firstname pah ug lastname.....

    mao ni function akong nahimo sa akong connection php gkan sa database

    function get_user($email,$index)
    {
    try
    {
    $db = new PDO(dbInfo,dbUser,dbPass);
    $sql = 'SELECT fname,lname,bday,gender,country,city,contact_num, bio FROM user_info WHERE email =?';
    $stmt = $db->prepare($sql);
    $stmt->execute();
    $first = "";
    $last = "";
    $bday = "";
    $gender = "";
    $country = "";
    $city = "";
    $contact = "";
    $bio = "";
    while($row = $stmt->fetch())
    {
    $first = $row['fname'];
    $last = $row['lname'];
    $bday = $row['bday'];
    $gender = $row['gender'];
    $country = $row['country'];
    $city = $row['city'];
    $contact = $row['contact_num'];
    $bio = $row['bio'];
    }
    $db = null;
    $u_info = array("Firstname"=>$first,"Lastname"=>$last,"Birth day"=>$bday,"Gender"=>$gender,"Country"=>$country, "City"=>$city,"Contact#"=>$contact,"Bio"=>$bio );
    return $u_info[$index];
    //return $email;
    }
    catch(PDOException $ex){ echo "Database Error", $ex->getMessage(); }
    } //get_user

    function getFname($email)
    {
    return get_user($email, "Firstname");
    }

    function getLname($email)
    {
    return get_user($email, "Lastname");
    }

    function getBday($email)
    {
    return get_user($email, "Birthday");
    }

    function getGender($email)
    {
    return get_user($email, "Gender");
    }

    function getCountry($email)
    {
    return get_user($email, "Country");
    }

    function getCity($email)
    {
    return get_user($email, "City");
    }

    function getContact($email)
    {
    return get_user($email, "Contact");
    }

    function getBio($email)
    {
    return get_user($email, "Bio");
    }
    ----------------------------------------------------------------
    nya php code nako sa akong profile.php na page

    <?php include ('connectDB.php');


    $getUser = "";
    session_start();
    if(!isset($_SESSION['email']))
    {
    header("Location:index.php");
    }
    else
    {
    $getUser = $_SESSION['email'];
    }
    ?>
    etc........
    daun diri -----> <ul>
    <li>Name: <?php echo getFname($getUser) . " " . getLname($getUser);?></li>
    etc.........
    </ul>
    -------------------------------------------------
    gah libog jud ko aning PDO.....pasensya kaau mga master sa akong problema

  2. #2
    basin limtan nimo ang email ani based saimo sql statement:
    $stmt = $db->prepare($sql);

    mrg dapat:
    $stmt = $db->prepare($sql, "ang emaill address");

  3. #3
    Quote Originally Posted by ondoy View Post
    basin limtan nimo ang email ani based sa imo sql statement:
    $stmt = $db->prepare($sql);

    mrg dapat:
    $stmt = $db->prepare($sql, "ang email address");
    unsay pasabot nmo master? ang email na field sa akong mysql?

    $stmt = $db->prepare($sql, "email")

    pasensya kaau mga master ha kay nag self-study rah ko aning php ug kaning PDO kay purting hinaya sa among discussion nya ang g tudlo pa gyud sa among instructor kay katong mysqli_connect which prone to sql injection kuno

  4. #4
    suwayi daw ani:
    $stmt = $db->prepare($sql, $email);

  5. #5
    Quote Originally Posted by ondoy View Post
    suwayi daw ani:
    $stmt = $db->prepare($sql, $email);
    mao ghapun master....ako lng sah i review ang logic ani nya kung d mada d nlng ko mo gamit aning PDO....salamat

  6. #6
    kalimot nmn gudko gamit ani
    $db->prepare($sql);
    $db->execute(array($email));
    or kini
    $db->execute($email);

  7. #7
    onsa pasabot ani nga statement?

    "'SELECT fname,lname,bday,gender,country,city,contact_num, bio FROM user_info WHERE email =?';"

    naa questionmark?

  8.    Advertisement

Similar Threads

 
  1. Is there no hope na ma in love ang girl....
    By Donzki in forum Relationships (Old)
    Replies: 41
    Last Post: 09-08-2010, 08:19 AM
  2. NIKON or CANON? :: no longer a pain in the patooty
    By backpacklife in forum Photography
    Replies: 1
    Last Post: 04-19-2008, 12:23 PM
  3. NUMBER SYSTEM TO HELP YOU IN LOTTO 642/649
    By bro_manny in forum General Discussions
    Replies: 14
    Last Post: 11-13-2007, 11:17 AM
  4. Replies: 6
    Last Post: 07-20-2007, 06:26 PM
  5. No "New Topic" tab in Buy and Sell section
    By *dudes* in forum Support Center
    Replies: 12
    Last Post: 07-11-2006, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top