PDA

View Full Version : PHP query - a minor problem?


duhuskermeg
08-09-2001, 01:39 PM
Hi all!!

I've been trying to get this thing to work, but I'm not that steady in PHP as I hoped. It's been a while since I worked with it the last time.

Let me first tell how this is supposed to work:
Underneath is a php-script that will get KursID as variable. Then, it will look up this variable from the database and return the post. The fields from this post will be sent as parameter when staring the flash-file.

If anyone can help me looking through the script and see what can be wrong, I would really appreciate it!! :)

I dont think its anything wrong in from the <object> tag, but what do I know.. (ahem..)

Well, here it is:

<?php
$db = mysql_connect("localhost", "aof", "pamtee");
mysql_select_db("aofkurs",$db);

if ($KursID) {
$sql = "SELECT * FROM kurs WHERE KursID=$KursID";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
}
?>

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
WIDTH=500 HEIGHT=450>
<PARAM NAME=movie VALUE="bestill.swf?KursID=<?php echo $KursID; ?>?Kurs_beskrivelse=<?php echo $Kurs_beskrivelse; ?>?Kurs_sted=<?php echo $Kurs_sted; ?>?Kurs_startdato=<?php echo $Kurs_startdato; ?>?Kurs_startklokke=<?php echo $Kurs_startklokke; ?>?Kurs_avgift=<?php echo $Kurs_avgift; ?>">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="bestill.swf?KursID=<?php echo $KursID; ?>?Kurs_beskrivelse=<?php echo $Kurs_beskrivelse; ?>?Kurs_sted=<?php echo $Kurs_sted; ?>?Kurs_startdato=<?php echo $Kurs_startdato; ?>?Kurs_startklokke=<?php echo $Kurs_startklokke; ?>?Kurs_avgift=<?php echo $Kurs_avgift; ?>" quality=high bgcolor=#FFFFFF WIDTH=500 HEIGHT=450 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>

nicewebguy
08-09-2001, 07:52 PM
It looks like you might want to hit your row set with extract() to bring its fields into the global name space:

extract($myrow);

This should go right after you set the variable to the result set. There are options for this function that you could check out: http://php.net/extract

Good luck,
doug

duhuskermeg
08-09-2001, 08:24 PM
Thanx..

Sorry if I'm a bit slow here, but in my case that would be like this:

extract($result); ...?



TranceMore

nicewebguy
08-09-2001, 08:50 PM
$result is just the id of result set - you want to extract the actual array that contains the data, no? In your script you've placed this into the $myrow variable. The mysql_fetch_array() function returns this hash array.

doug

duhuskermeg
08-09-2001, 08:57 PM
Oh, of course!! I'm a dumbass.. I was too quick to answer your post. I think I've got it now.. ;) Thanx.

So, if I implement this:

<?php
$db = mysql_connect("localhost", "aof", "pamtee");
mysql_select_db("aofkurs",$db);

if ($KursID) {
$sql = "SELECT * FROM kurs WHERE KursID=$KursID";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
extract($myrow);
}
?>

Then the whole script will work, as far as you can see? No other stupid mistakes .. ;)



TranceMore