Jump to content

[SOLVED] problem with: img src "<?php [to display stored Mysql Video file]?>


karnegyhall

Recommended Posts

i can't figure this f*'n problem.  The operative query works in phpmyadmin, but not from php.  it's dying on the query right now:

$displayimage = mysql_query("SELECT strVideoPath FROM tblathletevideos WHERE intAtheleteID='$ID'");
$result1 = mysql_query($displayimage) or die('Error, query failed');

 

however the end goal right now is what's written in the subject line.  Here is the full page's code. Please withhold any menial suggestions about my level of knowledge or derogatory comments about the way my code is written.  I'm sure there is a lot I could do better.  right now i am seeking HELP for fixing only this one problem.  thanks so much guys!

<?php
require_once('sports-auth.php');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="sportsCSSmod.php" rel="stylesheet" type="text/css" />
</head>
<body>
<?PHP
$ID = $_SESSION['SESS_MEMBER_ID'];
$conn = mysql_connect("DB_host", "DB_name", "Pwd"); 
if (!$conn)
{
  die('Could not connect: ' . mysql_error());
}
$select = mysql_select_db('DB', $conn);
if (!$select)
{
  die('could not select db: DB ' . mysql_error());
}
$result = mysql_query("SELECT strLastName FROM tblathletes WHERE intAthleteID='$ID'");
?>
<h1>Welcome <?php while($row = mysql_fetch_array($result)) echo $row['strLastName'];?></h1>
<a href="sports-memberprofile.php">Edit/Create Profile</a> | <a href="sports-logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<p>
<?php
$displayimage = mysql_query("SELECT strVideoPath FROM tblathletevideos WHERE intAtheleteID='$ID'");
$result1 = mysql_query($displayimage) or die('Error, query failed');
?>
<div align="center">
<p><img src="<?php while($row1 = mysql_fetch_array($result1)) echo $row1['strVideoPath'];?>"
?>
<p> </p>
<p>  <a href="index.htm">..Home</a>
</body>
</html>

Link to comment
Share on other sites

Are you sure you're getting a result?  A result set can return anywhere from 0 to many rows.  I think your assumption is that there will only be one row, but it could be possible that you're getting more than one.  If you only ever want one row, then you might consider a different fetch function.  At any rate, how about modifying to something like this to start.

 

One minor nitpick, but you should try and strive for always having being/end tags, so I stuck in your closing p tag.

 

 

    while($row1 = mysql_fetch_array($result1)) {
        echo "
";
   }

Link to comment
Share on other sites

to the first responder - the session_start() functiion is built into the page my require_once() points to, hence it is in the first line of the page.

 

to the second: i see your point.  you want to add a '\' before the path of the file, and after.  i did try adding that code.

it yields a parse error.

Parse error: syntax error, unexpected $end in /home/content/m/i/k/[********]/html/sports-memberindex.php on line 53

which i can usually fix.  but it's pointing to line 54, and that's wierd, b/c as you will see if you import the original page's code - 54 is my html end tag and the line before it is my end tag for /body.  I know the line the error occurs on is usually the line 'after' where the actual problem exists, so it seems to be indicating a problem with my </body> tag now???  HELP

 

 

Link to comment
Share on other sites

also, i have commented out the query, and imbedded the image file from the path that shows in phpmyadmin and it comes up fine. 

there has to be something wrong with my actual mysql_query, no?

 

Change this:

<?php
$displayimage = mysql_query("SELECT strVideoPath FROM tblathletevideos WHERE intAtheleteID='$ID'");
$result1 = mysql_query($displayimage) or die('Error, query failed');
?>

 

To:

<?php
$displayimage = "SELECT strVideoPath FROM tblathletevideos WHERE intAtheleteID='$ID'";
$result1 = mysql_query($displayimage) or die('Error, query failed');
?>

 

Hope this will help.

 

 

Link to comment
Share on other sites

anupamsaha!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

YOU ARE THE MAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I am forever indebted to you!!!!!!!!!!!!!!!!!!!!

And to you others for your attempts as well.  Thank you much.  This was driving me NUTS.

 

-Mike

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.