TNGuy03 Posted May 20, 2007 Share Posted May 20, 2007 I am trying to pull my file name from a database using the following code, grabbing the record id from the URL. I have confirmed that the id is held under $media for $query; however, I can't seem to get any results from the query itself, and no apparent query/connection errors. <?php require "cont/access.php"; $media = "$_GET[id]"; function showVideo($result) { print "\n<table border=1 align=center>\n<tr>\n" . "\n\t<th align=center><font size=2>Folder</font></th>" . "\n\t<th align=center><font size=2>File</font></th>" . "\n</tr>"; while($row=@mysql_fetch_assoc($result)) { // ... start a TABLE row ... print "\n<tr>"; // ... and print out each of the attributes in that row as a separate TD (Table Data). print "\n\t<td align=right><font size=2> $row[f] </font></td>"; print "\n\t<td align=right><font size=2> $row[n] </font></td>"; //Finish the row print "\n</tr>"; } //Then, finish the table print "\n</table>\n"; } showVideo($result); $query = "SELECT folder as f, f_name as n FROM Pages WHERE page_id = '$media' GROUP BY n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52270-solved-trouble-getting-results-from-query/ Share on other sites More sharing options...
Glyde Posted May 20, 2007 Share Posted May 20, 2007 You do understand you never even queried the database in that script using mysql_query, right? And you're also trying to pass the $result variable to showVideo, but $result hasn't been defined. You should have: $result = mysql_query($query) or die(mysql_error()); After you define $query but before you call showVideo Quote Link to comment https://forums.phpfreaks.com/topic/52270-solved-trouble-getting-results-from-query/#findComment-257898 Share on other sites More sharing options...
TNGuy03 Posted May 20, 2007 Author Share Posted May 20, 2007 Glyde, Yeah...I'm new to PHP - painfully obvious. Thanks for the tip. I am now able to see the result of the query, but one of the results is a file name, which I am now trying to put into an embedded media player for viewing in the user's web browser. While I am now seeing the results successfully as text, I cannot get the filename $row[n] to appear in the embedded media script. <?php require "cont/access.php"; $media=$_GET[id]; //Show the categories in an HTML <table> function showFile($result) { //Find out how many rows are available $rowsFound=@mysql_num_rows($result); //Start a table with column headers print "\n<table border=1 align=center>\n<tr>\n" . "\n\t<th align=center><font size=2>Folder</font></th>" . "\n\t<th align=center><font size=2>File</font></th>" . "\n</tr>"; //Until there are no rows in the result set, fetch a row into the $row array and ... while($row=@mysql_fetch_assoc($result)) { // ... start a TABLE row ... print "\n<tr>"; // ... and print out each of the attributes in that row as a separate TD (Table Data). print "\n\t<td align=right><font size=2> $row[f] </font></td>"; print "\n\t<td align=right><font size=2> $row[n] </font></td>"; //Finish the row print "\n</tr>"; } //Then, finish the table print "\n</table>\n"; //Report how many rows were found print "<center><br><font size=1><i>Top {$rowsFound} Audio Files (Real Time)</i></font><br></center>"; } $query="SELECT folder as f, f_name as n FROM Pages WHERE page_id = '{$media}' GROUP BY n"; //Connect to the MySQL server if(!($connection=@mysql_connect($hostName, $userName, $password))) die("Cannot connect"); if(!(mysql_select_db($databaseName, $connection))) showerror(); //Run the query on the connection if(!($result=@mysql_query($query, $connection))) showerror(); //Display the results showFile($result); echo " <OBJECT ID=MediaPlayer1 width=400 height=300 classid=CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95 CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 standby=Loading Microsoft® Windows® Media Player components... type=application/x-oleobject> <PARAM NAME=AutoStart VALUE=True> <PARAM NAME=FileName VALUE=/video/{$row[n]}> <PARAM NAME=ShowControls VALUE=True> <PARAM NAME=EnableContextMenu Value=False> <PARAM NAME=ShowStatusBar VALUE=True> <EMBED type=application/x-mplayer2 pluginspage=http://www.microsoft.com/Windows/MediaPlayer/ SRC=/video/{$row[n]} name=MediaPlayer1 width=400 height=300 autostart=1 showcontrols=1 enablecontextmenu=0 showstatusbar=1> </EMBED> </OBJECT>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52270-solved-trouble-getting-results-from-query/#findComment-257905 Share on other sites More sharing options...
Glyde Posted May 20, 2007 Share Posted May 20, 2007 Try adding print_r($row) inside your while loop to see what the contents of the row are. Quote Link to comment https://forums.phpfreaks.com/topic/52270-solved-trouble-getting-results-from-query/#findComment-257906 Share on other sites More sharing options...
TNGuy03 Posted May 20, 2007 Author Share Posted May 20, 2007 Glyde, The print_r($row) shows the same results that I confirmed with display in the table. The filename of the video clip I want to display (abc.wmv) is what is returned by the showFile function above. Now I want to take that filename ($row[n] from my query) and use it in the embedded media player. The player is loading but if I look at the HTML source from the browser the file name (abc.wmv aka $row[n]) is missing from the source code. Is this an issue with where I am placing the code for the embedded player? Regards Quote Link to comment https://forums.phpfreaks.com/topic/52270-solved-trouble-getting-results-from-query/#findComment-257913 Share on other sites More sharing options...
TNGuy03 Posted May 21, 2007 Author Share Posted May 21, 2007 Figured it out...it was a placement issue. I've moved the code for the embedded media into the 'while' loop and it is working well. Quote Link to comment https://forums.phpfreaks.com/topic/52270-solved-trouble-getting-results-from-query/#findComment-257925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.