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

Problems with array
This code is the last lines in an upload script that uploads 4 images at the same time and writes th

How to generate a text file using php...?
Hi,
Can anyone give me code to generate a text file using php


Thanks in advance

MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup

Help with file_get_html
The following code gives the expected results:

<html>
<head&g

Count
Getting the same count everytime

Code:
$visitquery = mysql_query("SELECT COUNT(*) FR

ImageCreate()
When I create an image and add text to it I want my text to be replaced with a PNG image, because th

filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I h

Undefined variable: adHTML
Hello:

While checking my site error logs, I've noticed one repetitive error that fills the lo

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

need to apply an if/else statement to Tim Thumb script
Not sure how to work this. I essentially want to call a variety of image sizes based on which style

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