Jump to content

What can cause an insert not to work?


divinedesigns1

Recommended Posts

ok i been trying to fix this error, and i am not able to insert the information into the database, the information in the db is correct, and the names for the form fields are correct also, but im still having problems inserting the information into the database. so i want to know what can cause the insert to not put the information into the database. because i havent figure it out as yet, can someone please give me a hand

Link to comment
Share on other sites

what does your error says? they have all the answers always.

Link to comment
Share on other sites

what does your error says? they have all the answers always.
no errors at all, var_dump(); displayed the strings, print_r(); displayed the strings also, i even echo it out, no errors on and i have error all on also still nothing
Link to comment
Share on other sites

have you check the mysql error?

Link to comment
Share on other sites

have you check the mysql error?
how you do that?
Link to comment
Share on other sites

mysql_error() or mysqli_error() if you are using one of those api http://php.net/mysql_errorhttp://php.net/mysqli_error

Edited by birbal
Link to comment
Share on other sites

mysql_error() or mysqli_error() if you are using those api http://php.net/mysql_errorhttp://php.net/mysqli_error
yeah, im using mysqli_error(); im not getting any errors from that either
Link to comment
Share on other sites

can you post the codes?

Link to comment
Share on other sites

Note: The session_start() and connection to the db is at the top of the pageill post a structure of the table below this reply in a few

<?phpif(isset($_SESSION['uid'])){// if log in display the below menu?><table align="center" width="800"><tr><td width="663"><?phpif(isset($_GET['action'])){$action = $_GET['action'];if($action == "news"){  // creating a new Blog	    echo '<h3>New Blog</h3>';   if(isset($_POST['submit'])){    $title = $_POST['title'];    $article = $_POST['article'];       if(empty($title) && empty($article)){	 echo 'Please Fill In All Fields';    }    if(!empty($title) && empty($article)){	 echo 'Article: ' . 'Some text is required';    }    if(empty($title) && !empty($article)){	 echo 'Title: ' . 'A Title Is Required';    }    if(!empty($title) && !empty($article)){	 // filter the title and article	 $title = mysqli_real_escape_string($con, $title);	 $article = mysqli_real_escape_string($con, $article);	 $title = stripslashes($title);	 $title = strip_tags($title);	 $article = stripslashes($article);	 $article = strip_tags($article); 		 $query = "INSERT INTO article(title, body, post_user) VALUES('$title', '$article', '" . $_SESSION['uid'] . "')";	 if(!$query){	  die('Error: ' . mysqli_error());	 }		 echo 'Your Blog Have Been Post';    }   }else{    ?>

Link to comment
Share on other sites

the table structure

id int(11) ac primarytitle varchar(255)body textnid int(11) index
Link to comment
Share on other sites

you are not using mysqli_query(). it is just assigning the query not executing it. you will check the return value of mysqli_query() and you will pass the $query as parameter in the mysqli_query() http://php.net/mysqli_query

Edited by birbal
Link to comment
Share on other sites

you are not using mysqli_query(). it is just assigning the query not executing it. you will check the return value of mysqli_query() and you will pass the $query as parameter in the mysqli_query() http://php.net/mysqli_query
thank you very much, i though it wouldnt matter if i had the mysqli_query() or not, thanks birbal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...