I am trying to learn php to manipulate MySQL data. I setup a simple input form and a script to insert a record to the database. I tried the code in a working web site and it works fine, but when I try it in my local practice machine it won't insert the record, but I do not receive any errors. Since it works in a live web site I am thinking it could be something with the MySQL setup. I wonder if ideas of things that could stop this from working? The 2 scripts are:
<form action="process.php" method="post">
Your ID: <input type="int(4)" name="id"><br>
Date: <input type="date" name = "day"><br>
Clock In: <input type="time" name = "clockin">
Clock Out: <input type="time" name = "clockout">
<br>
<input type="submit" value="Submit">
</form>
<?
$id=$_POST['id'];
$day=$_POST['day'];
$clockin=$_POST['clockin'];
$clockout=$_POST['clockout'];
mysql_connect("localhost", "john", "Maintenance1") or die(mysql_error());
mysql_select_db("comptechdev") or die(mysql_error());
mysql_query("INSERT INTO clocks (id,day,clockin,clockout) VALUES ('$id', '$day', '$clockin','$clockout')");
Print "Your information has been successfully added to the database.";
?>
The message Print ... never posts, all I get is a blank screen.
I am using Apache 2.22, MySQL 5.6.10, PHP 5.4.13 and phpMyAdmin 3.5.8. I can insert records manually using phpMyAdmin and all tests indicate that my setup is working properly.
I will greatly appreciate any feedback, I know this is vague, but I figure there may be some setting I am missing.
Mike.
<form action="process.php" method="post">
Your ID: <input type="int(4)" name="id"><br>
Date: <input type="date" name = "day"><br>
Clock In: <input type="time" name = "clockin">
Clock Out: <input type="time" name = "clockout">
<br>
<input type="submit" value="Submit">
</form>
<?
$id=$_POST['id'];
$day=$_POST['day'];
$clockin=$_POST['clockin'];
$clockout=$_POST['clockout'];
mysql_connect("localhost", "john", "Maintenance1") or die(mysql_error());
mysql_select_db("comptechdev") or die(mysql_error());
mysql_query("INSERT INTO clocks (id,day,clockin,clockout) VALUES ('$id', '$day', '$clockin','$clockout')");
Print "Your information has been successfully added to the database.";
?>
The message Print ... never posts, all I get is a blank screen.
I am using Apache 2.22, MySQL 5.6.10, PHP 5.4.13 and phpMyAdmin 3.5.8. I can insert records manually using phpMyAdmin and all tests indicate that my setup is working properly.
I will greatly appreciate any feedback, I know this is vague, but I figure there may be some setting I am missing.
Mike.