merlin371 Posted March 5, 2010 Share Posted March 5, 2010 Hey guys sorry if this is a really noobie question but i tried everything and i cant see why it wont work, I have a form that would send the information to another page that in theory puts the data into the database however it does nothing, it wont even give me an error, this is what i have on the page. include("config.php"); $db_link = mysql_connect($db_server, $db_uname, $db_pass); mysql_select_db($db_name, $db_link); if (isset($_POST['user'])) { $user = $_POST['user']; $date = $_POST['date']; $time = $_POST['time']; $device = $_POST['device']; $info = $_POST['info']; mysql_query ("INSERT INTO `alanz`.`logs` (`id`, `user`, `date`, `time`, `device`, `info`) VALUES (NULL, '".$user."', '".$date."', '".$time."', '".$device."', '".$info."');", $db_link); } any idea why it wont do anything? thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2010 Share Posted March 5, 2010 Best guess is that your form is not setting $_POST['user'], so the code you did post is being skipped over. Quote Link to comment Share on other sites More sharing options...
merlin371 Posted March 5, 2010 Author Share Posted March 5, 2010 no it works, i'm echoing a message between the brackets to see if it goes trough, i just didnt put it here. and that shows all the time. Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 5, 2010 Share Posted March 5, 2010 You have nothing in that script that would give you any errors if something was not right. I suspect either the POST value is not set or there is a database error. Try this: <?php include("config.php"); $db_link = mysql_connect($db_server, $db_uname, $db_pass) or die ("unable to connect to database server"); mysql_select_db($db_name, $db_link) or die ("unable to select to database"); if (!isset($_POST['user'])) { echo "The post value for 'user' is not set."; } else { $user = mysql_real_escape_string(trim($_POST['user'])); $date = mysql_real_escape_string(trim($_POST['date'])); $time = mysql_real_escape_string(trim($_POST['time'])); $device = mysql_real_escape_string(trim($_POST['device'])); $info = mysql_real_escape_string(trim($_POST['info'])); $query = "INSERT INTO `alanz`.`logs` (`user`, `date`, `time`, `device`, `info`) VALUES ('{$user}', '{$date}', '{$time}', '{$device}', '{$info}')" mysql_query ($query, $db_link) or die ("Query:<br />{$query}<br />Error:<br />" . mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
merlin371 Posted March 5, 2010 Author Share Posted March 5, 2010 ya it works now thanks a lot man, turns out i had put the date field on mysql as date and i was putting in the date in a wrong manner, fixed it now, that messages helped a lot Quote Link to comment 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.