More Mysqli Errors

Status
Not open for further replies.

dreamc90

New Member
Messages
7
Reaction score
0
Points
0
hey all having problems iwth mysqli insert statements, anyone have aclue, here's my problem.
$mysqli = new mysqli($host, $user, $pass, $db_Name);
$mysqli->query("INSERT INTO USER (USERID, USERNAME, USERPASSWORD, USERFIRSTNAME, USERLASTNAME, USERADDRESS, USERCITY, USERSTATE, USERZIPCODE, USERCOUNTRY, USERPHONE1, USERPHONE2, USERFAX, USEREMAIL) VALUES ('NULL', '{$email}', '{$pass}', '{$fName}', '{$lName}', '{$address}', '{$city}', '{$state}', '{$zip}', '{$country}', '{$phone1}', '{$phone2}', '{$fax}', '{$email}'{

all variables here are set, and USERID is auto_increment, zip, phone1, phone2 and fax are numbers, ALSO userid is PK

[TD}]Everything appears to dubmit but the info id not reflected in the database.[/TD]
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. What is the problem? Error messages? Do you test any return values?

2. Not sure why you use {$variable} syntax

3. Setting a variable to the query string:

$my_query_string = ......................
$mysqli->query($my_query_string)

is much easier to debug because you can print out the string.
 

dreamc90

New Member
Messages
7
Reaction score
0
Points
0
Yes I'm testing different values and have tried various ways I j putting the data, namely the way you've shown using string and har tried without curly's, without quotes etc. sometimes I'll get the _T_Object error message other times I'll get a success but it never actually inserts data into the database. Btw I've also true using te phpadmin and it worked there as well.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
do you test $mysqli ?

Do you test the return from $mysqli ?

Do you ever check $mysqli->error ?
 

dreamc90

New Member
Messages
7
Reaction score
0
Points
0
PHP:
$mysqli = new mysqli($host, $user, $pass, $db_Name);
    
$query ="INSERT INTO USER (USERNAME, USERPASSWORD, USERFIRSTNAME, USERLASTNAME, USERADDRESS, USERCITY, USERSTATE, USERZIPCODE, USERCOUNTRY, USERPHONE1, USERPHONE2, USERFAX, USEREMAIL) VALUES ('$email', '$pass', '$fName', '$lName', '$address', '$city', '$state', '$zip', '$country', '$phone1', '$phone2', '$fax', '$email')";     

 if(!$result = $mysqli->query($query)) 
 { 
          die($mysqli->error);
      }

Generates this: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USER (USERNAME, USERPASSWORD, USERFIRSTNAME, USERLASTNAME, USERADDRESS, USERCITY' at line 1
 
Last edited:

dreamc90

New Member
Messages
7
Reaction score
0
Points
0
Also just tried this:
PHP:
$mysqli = new mysqli($host, $user, $pass, $db_Name);

 $query = $mysqli->prepare("INSERT INTO USER (USERNAME, USERPASSWORD, USERFIRSTNAME, USERLASTNAME, USERADDRESS, USERCITY, USERSTATE, USERZIPCODE, USERCOUNTRY, USERPHONE1, USERPHONE2, USERFAX, USEREMAIL) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
      
$query->bind_param("sssssssisiiis", $email, $pass, $fName, $lName, $address, $city, $state, $zip, $country, $phone1, $phone2, $fax, $email);
      
$query->execute();

Now I get this error:
Fatal error: Call to a member function bind_param() on a non-object in /home/dreamc90/public_html/checkRegister.php on line 271
 
Last edited:

dreamc90

New Member
Messages
7
Reaction score
0
Points
0
Aye yae yae... Stupid stupid. I ended up testing with this:
PHP:
if ($stmt === FALSE) {
    die ("Mysql Error: " . $mysqli->error);

Of course it found USERZIPCODE was spelled incorrectly.... Thanks for the help descalzo..
 
Status
Not open for further replies.
Top