tags:

views:

37

answers:

2

I'm trying to explode a string into an array. A fullname to be exploded in firstname, middlename, and lastname.

  <?php

    include('conn.php');

    $un=$_POST['uname'];
    $pw=$_POST['pw'];
    $fulnem=$_POST['fullnem'];
    $temp=explode('/',$fulnem);

    $email=$_POST['email'];

    $method="creates";





    $sql="call compactproc('$un', '$pw', '$temp[0]', '$temp[1]', '$temp[2]', '$email', '$method')";
    $result=mysql_query($sql);
    if(!$result){
    echo "error!";

    }



    ?>

Here's the procedure body:

BEGIN

IF actions="creates" THEN
INSERT INTO admin_table(Uneym, Pwerd, Firstname, Middlename, Lastname, Email) VALUES(usrname, psword, frstname, midname, lstname, imail);
END IF;
END

Only the firstname is stored in the database. Why is it? The midname and lastname doesnt get stored and I get the undefined offset error on the line of the sql query. can you tell me what's the problem here.

A: 

You may need to explode with a space   instead of a / :

 $temp=explode(' ',$fulnem);
shamittomar
A: 

I hope you should not use single quote(') in parameters of call compactproc.

nik