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

Multidimensional Array into an Html table, help!
Hello all, I am new to HTML/PHP so any help would be great.

I have a multidimensional array f

for some reason mysql query not working, not inserting, please check it out
This code is not inserting anything into my db, don't know why, the $_SESSION variable does contain

Displaying image from database
Hi,

I've got a site where that's got a database behind it. Currently it has loads of items in

my login script page is not working on remote computers
hi my login is working on my computer, but when i tried 2 computers from 2 different locations, they

Displaying a record from mysql in a simple swf file
Hi,

I have a mysql database containing information I would like to display in my swf.

get multiple rows
Hi I want to get multiple rows from a db

I am using this for the db query
Code: public

Change of partner analyse in sales orders
Hello,

I changed the partner analyse for sales orders and added a new mandatory partnerro

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

Expandable Post Code
Hi,

Hope you can help. Which currently I haven't upgraded to connect to a mysql server, so i

Limiting checkboxes?
Hi guys,

I have this code: Code: if(isset($_POST['selected'])) {
foreach($_POST['selec

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