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.

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

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

Trouble with a select list
Hello All!
I was wondering if any of you guys could help me with a small problem I'm having!

Update Database
Hi All,


I have a problem with this:

Code: [Select]<?php
session_start();

Need help/w Page: 1,2,3,4 function!
So I have this code im working on where it's ment to display seperate pages having 20 logs each
I

How to submit a form to the same page?
I have a table containing information about books in my library and this table has the following col

Request.UrlReferrer
I need to make it so that a page can only be loaded when a button is clicked on a specific page. I d

Beginner question regarding Array's
Hi everyone, the page im working on has an array of variable at the top...

Code: $define_li

quick question
Hi ..

i have a question
how do i set a var so it displays via an echo
Code: $logo = '&a

$get problem
Hi Guys ...

can you please tell me what i am doing wrong here
Code: <?php

Error with Font and imagettfbbox
I keep getting an error that says "Warning: imagettfbbox() [function.imagettfbbox]: Could not f

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