sanderphp Posted May 16, 2008 Share Posted May 16, 2008 I had this code working, but then I changed the way I was creating the date and now my code isn't working. Not getting any errors though. Is my date code that I'm using to combine the year, month, day to the format 20080516 incorrect and causing my problem? <?php session_start(); $host="localhost"; // Host name $username="sanderan_admin"; // Mysql username $password="password"; // Mysql password $db_name="sanderan_cycling"; // Database name $tbl_name="riders"; // Table name // Connect to server and select databse. $conn = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //Pick up the form data and assign it to variables (if it was submitted) if(isset($_POST['date'])){ $datemonth = $_POST['datemonth']; $dateyear = $_POST['dateyear']; $dateday = $_POST['dateday']; $date = "$dateyear-$datemonth-$dateday"; $total_distance = $_POST['total_distance']; $total_time = $_POST['total_time']; $ave_speed = $_POST['ave_speed']; $rider_id = $_SESSION['login_id']; // Insert data $query = "INSERT INTO info (date, total_time, total_distance, ave_speed, rider_id) VALUES ('$date', '$total_time', '$total_distance', '$ave_speed', '$rider_id')"; mysql_query($query) or die(mysql_error()); //echo '<pre>', print_r($_POST, true), '</pre>'; //show all inputs //echo '<pre>', print_r($_SESSION, true), '</pre>'; //show session variables // Close connection mysql_close($conn); // Redirect header("Location: submit_success.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/105985-solved-help-troubleshooting-code/ Share on other sites More sharing options...
Barand Posted May 16, 2008 Share Posted May 16, 2008 Define "isn't working" Link to comment https://forums.phpfreaks.com/topic/105985-solved-help-troubleshooting-code/#findComment-543187 Share on other sites More sharing options...
LooieENG Posted May 16, 2008 Share Posted May 16, 2008 Try $date = $dateyear . '-' . $datemonth . '-' . $dateday'; Or is it supposed to be minus? Link to comment https://forums.phpfreaks.com/topic/105985-solved-help-troubleshooting-code/#findComment-543188 Share on other sites More sharing options...
sanderphp Posted May 16, 2008 Author Share Posted May 16, 2008 When I submit my form I just get a white screen and it doesn redirect. I don't need the minus, but I was under the impression I needed the dashes in there to concatenate the 3 date fields so I can get it in the correct format for MySQL. like 20080516 Link to comment https://forums.phpfreaks.com/topic/105985-solved-help-troubleshooting-code/#findComment-543190 Share on other sites More sharing options...
Barand Posted May 16, 2008 Share Posted May 16, 2008 Do you have a form field "date"? The processing takes place only if $_POST['date'] is set Link to comment https://forums.phpfreaks.com/topic/105985-solved-help-troubleshooting-code/#findComment-543192 Share on other sites More sharing options...
sanderphp Posted May 16, 2008 Author Share Posted May 16, 2008 oh jeez!!! I was really banging my head on this one too. I had a 'date' before I changed it to the concatenation method. Thanks again guys. Link to comment https://forums.phpfreaks.com/topic/105985-solved-help-troubleshooting-code/#findComment-543194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.