Collegeboox Posted October 10, 2011 Share Posted October 10, 2011 information not posting into the database the code below is the check code/insert code. Please if anyone knows why let me know. [color=red]<?php //msut be logged in page session_start(); if ($_SESSION['username']) { echo""; } else die("You must log in first!"); //form information $submit = $_POST['submit']; $row4 = $_SESSION['username']; // form data $link = strip_tags($_POST['link']); $message = strip_tags($_POST['message']); $title = strip_tags($_POST['title']); $author = strip_tags($_POST['author']); $date = date('Y-m-d'); $connect = mysql_connect("db","username","password") or die("Not connected"); mysql_select_db("username") or die("could not log in"); $querycheck = "SELECT * FROM boox WHERE username='$row4'"; $result = mysql_query($querycheck); while($rowz = mysql_fetch_array($result)) $linkcheck = $rowz['link']; if ($submit) { if($link&$title&$author) { // check username and subject lentgh if ($linkcheck == $link) { die ("This link has already been posted."); } else { //open database $connect = mysql_connect("db","username","password") or die("Not connected"); mysql_select_db("username") or die("could not log in"); $queryreg = mysql_query("INSERT INTO boox Values ('','$row4','$link','$title','$author','$message','$date')"); echo "You have just officialy posted on the Catalina Beat Mixers. "; } } } else { die ("You forgot to put something in the link/title/author box."); } ?>[/color] [code] Quote Link to comment https://forums.phpfreaks.com/topic/248834-information-not-inserting-into-database/ Share on other sites More sharing options...
jcbones Posted October 10, 2011 Share Posted October 10, 2011 De-bugging added, please copy/paste the error that is printed to the screen. <?php //msut be logged in page session_start(); //display all errors. error_reporting(-1); ini_set('display_errors',1); if ($_SESSION['username']) { echo""; } else die("You must log in first!"); //form information $submit = $_POST['submit']; $row4 = $_SESSION['username']; // form data $link = strip_tags($_POST['link']); $message = strip_tags($_POST['message']); $title = strip_tags($_POST['title']); $author = strip_tags($_POST['author']); $date = date('Y-m-d'); $connect = mysql_connect("db","username","password") or die("Not connected"); mysql_select_db("username") or die("could not log in"); $querycheck = "SELECT * FROM boox WHERE username='$row4'"; $result = mysql_query($querycheck) or trigger_error(mysql_error()); //error trigger added. while($rowz = mysql_fetch_array($result)) $linkcheck = $rowz['link']; if ($submit) { if($link&$title&$author) { // check username and subject lentgh if ($linkcheck == $link) { die ("This link has already been posted."); } else { //database is already open $queryreg = mysql_query("INSERT INTO boox Values ('','$row4','$link','$title','$author','$message','$date')") or trigger_error(mysql_error()); //added a error trigger on query failure. echo "You have just officialy posted on the Catalina Beat Mixers. "; } } } else { die ("You forgot to put something in the link/title/author box."); } ?> [code] Quote Link to comment https://forums.phpfreaks.com/topic/248834-information-not-inserting-into-database/#findComment-1277893 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.