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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

 formating when pulling data from a mysql database 
Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue.

I

Had a simple form script that suddenly stopped working
It was made about a year ago and had been working fine. Last time it was known to work for sure was

Comparing Values
Hi
I'm reading data from a database and this seems to work OK.

Each system has an associat

Save remote XML to local website folder
Hi, I hope you can help me out. I would like to be able to pull an XML file from another site and t

Help with PHP Email Script
Hi guys,

I'm a newbie to php and need help with the script below:

At the moment when I

Taxonomy? Classification? Categorisation?
Not sure if there is a way around this classification problem
I have a supplier who produces

add to sql result
ok see rite now my sites hit counter is counted from the mysql visitor log i need to clear it aft

why this query can delete duplicates ?
why this query can delete duplicates ? Anybody can give me the detailed explanation ?

Tha

how to hide input fields on selection screen using variant attribute
Hello all,

I want to know how to hide input fields on selection screen using variant attr

records between 2 dates
Hello all,

I have a date tracked table which contains effective_start_date and effective

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