Jump to content

PHP With MySQL -- Creating Views


Celcius

Recommended Posts

I need to create a view though a PHP execution.

Here is my code, the views are not being created, and thus my

while($row = mysql_fetch_array($result))

is giving me this error.

 

"Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ..."

 

I have checked my MySQL queries and they seem to be in working order when directly executed.

 

if($going == "1")
{
	echo "ENTERING INCOMING";

	$sql = mysql_query("CREATE VIEW inRangeIncoming AS SELECT f.flightNum, f.source, f.destination, i.actDate, i.plannedTime, i.actualTime FROM joinedIncoming i, flights f WHERE (i.plannedTime BETWEEN \'$timeStart\' AND \'$timeEnd\') AND (i.actDate = \'2010-03-31\') AND (f.flightNum = i.flightNum)");
	$result = mysql_query("SELECT * FROM inRangeIncoming");
}
elseif($going == "2")
{
	echo "ENTERING OUTGOING";

	$sql = mysql_query("CREATE VIEW inRangeOutgoing AS SELECT f.flightNum, f.source, f.destination, i.actDate, i.plannedTime, i.actualTime FROM joinedOutgoing o, flights f WHERE (i.plannedTime BETWEEN \'$timeStart\' AND \'$timeEnd\') AND (o.actDate = \'2010-03-31\') AND (f.flightNum = o.flightNum)");

	$result = mysql_query("SELECT * FROM inRangeOutgoing");
}

Link to comment
https://forums.phpfreaks.com/topic/197069-php-with-mysql-creating-views/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.