Jump to content

[SOLVED] help with mysql_error()


priyankabhar

Recommended Posts

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.

 

Priya.

 

 

It echo's that

 

 

Link to comment
https://forums.phpfreaks.com/topic/181045-solved-help-with-mysql_error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.