Good Day Everyone,
I'm a new user of PHP and Apache server and most ofd the error found in the error logs are very new to me. My colleagues told me to stop studying the thre buddys (Apache, PHP and MySQL) but I am very interested to learn and someday I can be a great help also here in this forum and my work.
By using the form and using "POST" I can connect to my data base but in loading new record, no error in the logs can be found but in the PHP statement to know where is the wrong in the program, the mysql_query cannot proced" Couldn't execute query.". What's wrong with my program? I realy need to know and thank you for your effort. Please refer below for the program...
<?php
if ((!$POST["Rout_Num"]) || (!$POST["Date_Rec"]) || (!$POST["Time_Rec"]) || (!$POST["Off_Of"]) || (!$POST["Subject"]) || (!$POST["Rout_To"])) {
header("Location: http://localhost/VMO/new_communication.html");
exit;
} else {
$Rout_Num = $_POST["Rout_Num"];
$Date_Rec = $_POST["Date_Rec"];
$Time_Rec = $_POST["Time_Rec"];
$Off_Of = $_POST["Off_Of"];
$Subject = $_POST["Subject"];
$Rout_To = $_POST["Rout_To"];
}
?>
<HTML>
<HEAD>
<TITLE>Communication Database</TITLE>
</HEAD>
<BODY>
<H1>Adding New Record to recieved table</H1>
<?php
$sql="INSERT INTO recieved (Rout_Num, Date_Rec, Time_Rec, Off_Of, Subject, Routed_To) VALUES ('$Rout_Num', '$Date_Rec', '$Time_Rec', '$Off_Of', '$Subject', '$Rout_To')";
//create connection
$connection=mysql_connect("localhost", "root", "******") or die ("Couldn't connect to server.");
//select database
$db=mysql_select_db("vmo",$connection) or die ("Couldn't select database.");
//execute SQL query and get result
$sql_result=mysql_query($sql,$connection) or die ("Couldn't execute query.");
if (!$sql_result) {
echo "<P>Couldn't add record!";
} else {
echo "
<P>Record Added!</P>";
}
?>
</BODY>
</HTML>
Have a nice day..
Sandie
sandieflores@yahoo.com