priyankabhar Posted November 10, 2009 Share Posted November 10, 2009 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 More sharing options...
Mchl Posted November 10, 2009 Share Posted November 10, 2009 You're using mysqli so you need to use mysqli_error Link to comment https://forums.phpfreaks.com/topic/181045-solved-help-with-mysql_error/#findComment-955257 Share on other sites More sharing options...
priyankabhar Posted November 11, 2009 Author Share Posted November 11, 2009 Thanks a lot!!! Link to comment https://forums.phpfreaks.com/topic/181045-solved-help-with-mysql_error/#findComment-955444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.