Date & php & SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spangle1187
Forum Newbie
Posts: 2
Joined: Fri Dec 03, 2010 4:27 am

Date & php & SQL

Post 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);
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Date & php & SQL

Post 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
spangle1187
Forum Newbie
Posts: 2
Joined: Fri Dec 03, 2010 4:27 am

Re: Date & php & SQL

Post by spangle1187 »

thanks for that info. Any ideas what is wrong with this echo statement?

Code: Select all

echo '<td>'.$info['roomName']."</td>";
curlybracket
Forum Commoner
Posts: 59
Joined: Mon Nov 29, 2010 2:40 pm

Re: Date & php & SQL

Post by curlybracket »

yes, change '<td>' to "<td>"
Post Reply