help with mysql_error()


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I am trying to insert data into a table, but I am not able to insert it. I wanted to see what the error was using mysql_error() function, but it does not return any error string for me. I have pasted the code below. Any ideas where I am going wrong would be greatly appreciated.

global $error;
$link = mysqli_connect('localhost','root','');
if($link) {
$dbName = 'movieStore';
if(mysqli_select_db($link, $dbName)) {
$query = "INSERT INTO Movie(movieName,movieID, movieDescription) VALUES ('$movieName', '$movieID', '$movieDescription')";
$result = mysqli_query($link, $query);
if($result) {
$error = "Movie: $movieName successfully created";
}
else {
$error = "Error in your SQL: $query";
echo mysql_error();

}
}
else {
$error = "Unable to connect to $dbName";
}
}
}
echo $error;

It echoes that "Error in your SQL:INSERT INTO Movie(movieName,movieID, movieDescription) VALUES ('gg', '1', '') "

However, it does not print our what the error was while inserting.

Thanks a lot for looking into this

No comments posted yet

Your Answer:

Login to answer
141 Like 10 Dislike
Previous forums Next forums
Other forums

upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t

Socket programming
Hello all,

I have a PHP socket script. GPS trackers connect to this socket. IMEI verification

Undefined offset
The following script checks to see if the user answer matches the correct answer.

Form Fiel

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

Read from a text file after a specific word
Hi all.

I have a text file that looks like the one below.
I know how to open the text fi

IP Logger for Voting Script
Can anybody help me place an IP logger into my voting script?
I know that maybe it is not as secu

query help
Hi experts.

i have a table rep2 like this
PROD_COD ACCT_NO DUE_DAYS BALANCE

Code clarification
Hi

In the following code what could be the "search_print()" and where it could be

Could Someone Please Debug This?
I was wondering if someone could debug this script for me. I realize it's not the tidest script (and

Forms Authentication and Refresh at Login page
Hello, When I try to press the Login button in my webapplication at my login.aspx page nothing h

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash