karnegyhall Posted May 31, 2009 Share Posted May 31, 2009 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 https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/ Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 Add session_start() to the top of the script. Link to comment https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/#findComment-846437 Share on other sites More sharing options...
gizmola Posted May 31, 2009 Share Posted May 31, 2009 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 https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/#findComment-846438 Share on other sites More sharing options...
karnegyhall Posted June 1, 2009 Author Share Posted June 1, 2009 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 https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/#findComment-846937 Share on other sites More sharing options...
karnegyhall Posted June 1, 2009 Author Share Posted June 1, 2009 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? Link to comment https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/#findComment-846956 Share on other sites More sharing options...
anupamsaha Posted June 1, 2009 Share Posted June 1, 2009 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 https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/#findComment-846961 Share on other sites More sharing options...
karnegyhall Posted June 1, 2009 Author Share Posted June 1, 2009 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 https://forums.phpfreaks.com/topic/160400-solved-problem-with-img-src/#findComment-846970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.