Jump to content

[SOLVED] Help troubleshooting code


sanderphp

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.