Page 1 of 1

Date & php & SQL

Posted: Fri Dec 03, 2010 4:37 am
by spangle1187
I am a newbie to php and working on my first project:

I have created a MySQl database and working on some functionality between the php page and MySQL db. I have connected the php page to the db but I am now trying to pass a date variable into a mysql_query and keep getting the following error:

Parse error: parse error in C:\wamp\www\NEW Booking Folder\index.php on line 5

Code: Select all

include("php/dbconnect.php"); //connects to the database

//
var $date = CURDATE();
 

$result = mysql_query( //collects that data from the table
	"SELECT `Room`.`roomName`, `booking`.*
FROM Room, booking
WHERE (`booking`.`bookingDate` =$date)"
	);

	
	//inserts the bookings data into an array called info
	$info = mysql_fetch_array($result);

Re: Date & php & SQL

Posted: Fri Dec 03, 2010 7:27 am
by curlybracket
You are using currdate() in a wrong way.
1. Not curdate() but currdate()
2. It is not PHP function, it is SQL
3. Example:

Code: Select all

SELECT * FROM table WHERE DATE = curdate()
4. No "var" before variable in PHP:

Code: Select all

var $myVar = 4; // parse error
$myVar = 4; // ok

Re: Date & php & SQL

Posted: Fri Dec 03, 2010 8:28 am
by spangle1187
thanks for that info. Any ideas what is wrong with this echo statement?

Code: Select all

echo '<td>'.$info['roomName']."</td>";

Re: Date & php & SQL

Posted: Fri Dec 03, 2010 9:59 am
by curlybracket
yes, change '<td>' to "<td>"