php - While making a simple form, I get a "Fatal error: Uncaught Error: Call to a member function query()" -
fatal error: uncaught error: call member function query() on string in c:\xampp\htdocs\boobae\index.php:58 stack trace: #0 {main} thrown in
c:\xampp\htdocs\boobae\index.php on line 58
here code:
<?php include './include/header.include.php'; ?> <?php include './include/connect.include.php';?> <?php $reg = @$_post['reg']; //declaring variables prevent errors $fn = ""; $ln = ""; $un = ""; $em = ""; $em2 = ""; $pswd = ""; $pswd2 = ""; $d_birth = ""; $d = ""; $u_check = ""; $phone_number = ""; $conn=""; //registration form $fn = strip_tags(@_post['fname']); $ln = strip_tags(@_post['lname']); $un = strip_tags(@_post['uname']); $em = strip_tags(@_post['email1']); $em2 = strip_tags(@_post['email2']); $pswd = strip_tags(@_post['passwprd1']); $pswd2 = strip_tags(@_post['password2']); $d_birth = strip_tags(@_post['dbirth']); $d = ('y-m-d'); $phone_number = strip_tags(@_post['phone_number']); if (isset($_post['reg'])) { if ($em==$em2) { } else { echo "your emails not match!"; } if ( strlen($un)>25||strlen($fn)>25||strlen($ln)>25) { echo "the maximum limit username/first name/last name 25 characters"; } if (strlen($pswd)>30||strlen($pswd)<5) { echo "your password must 5 30 characters long"; } if ($fn&&$ln&&$un&&$em&&$em2&&$pswd&&$pswd2) { } else{ echo "please fill in fields!";} if ($pswd==$pswd2) { } else { echo "your pasword not match!"; } $sql="insert userss (username,first_name,last_name, email, password, d_birth, sign_up_date, $phone_number,activated) values ('$un', '$fn', '$ln', '$em', '$pawd', '$d_birth', '$d', '$phone_number')"; //$insert=$con->query($sql); } if ($conn->query($sql) === true) { echo "new record created successfully"; } else { echo "error: " . $sql . "<br>" . $conn->error; } $conn->close();
you set $conn="";
right under $phone_number = "";
. $conn
needs database connection, not string
Comments
Post a Comment