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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.