I've searched google and on here and some info has been useful but mostly not so useful and still can't manage to query my database using php. I'm very new to coding so thought it best to find an answer based on my code rather than other peoples slightly different problems. I have a small database, people fill in a form who wish to hire a bus. i have created a calendar and wish to print out for each day what time and for how long there is a hire, if there is one, based on the data people have entered which has been sent to my database. The whole page shows but the calendar contains an error within its table saying:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2013-03-01' at line 1"
even if i delete the "where date=.." part of the query it continues to show this. ive tried several different methods of writing the code out, including a loop and not including one but im not really sure what im meant to do.
EDIT: MY CODE IS NOW:
<?php
$con = mysql_connect("localhost","user","password");
$result = mysql_query("SELECT time, length FROM hire WHERE date='01-03-13'");
$row = mysql_fetch_assoc($result);
$Time = $row['TIME'];
$Length = $row['LENGTH'];
echo "Time: " . $TIME . "<br/>";
echo "Length: " . $LENGTH . "<br/>";
?>
I now get the error "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Users\Laura\Documents\COMPY\server\www\calendar.php on line 123" It shows the page, calendar and "time" and "length" but with the error and no data
EDIT
<?php
$con = mysql_connect("localhost","user","password");
mysql_select_db("busassociation", $con);
$result = mysql_query("SELECT time, length FROM hire WHERE date='01-03-13'");
while ($row = mysql_fetch_assoc($result)){
$time = $row['time'];
$length = $row['length'];
echo "time: " . $time . "<br/>";
echo "length: " . $length;
}
?>