i have just written a simple code to insert a row to my database called profiles but it doesn't work .
code:
<?php
$mysqli= new mysqli("localhost", "****", "****", "****");
if (mysqli_connect_errno()) {
throw new Exception("Unable to connect to the database. Error number: " . $this->mysqli->connect_errno);
}
$result = mysqli_query($mysqli,"INSERT INTO 'profiles' VALUES ( aaa , aaa , aaa , aaa , aaa , aaa , 1 , 1 , 0 , aaa , 0 )");
if($mysqli->affected_rows <= 0){
throw new Exception("Unable to add record in the database! Query returned: " . $result);
}
echo "1";
?>
my database :
1 username varchar(20)
2 password varchar(200)
3 email varchar(20)
4 name varchar(20)
5 city varchar(200)
6 address varchar(200)
7 mf varchar(5)
8 pp varchar(5)
9 reputation varchar(20)
10 register_date varchar(20)
11 kh_f varchar(5)
and the error log:
[18-Jul-2014 12:32:50 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'Unable to add record in the database! Query returned: ' in /home/***/***/***/**/test.php:9
Stack trace:
#0 {main}
thrown in /home/***/***/***/**/test.php on line 9
thanks in advance !
Please use mysqli_error()
to get your error ;)
And add quote to your strings : $result = mysqli_query($mysqli,"INSERT INTO profiles VALUES ( 'aaa' , 'aaa' , 'aaa' , 'aaa' , 'aaa' , 'aaa' , '1' , '1' , '0' , 'aaa' , '0' )");
"INSERT INTO 'profiles' VALUES ..."
NOT 'profiles'
but profiles
with button that is located on the left side of 1(!)
i can't write this sign because bbcode parse it as code