Jump to content


Photo

PHP expert needed to find error in this code!


  • Please log in to reply
2 replies to this topic

#1 essjay_d12

essjay_d12
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 14 March 2006 - 07:30 PM

The following code gets the get variable (i echoed it) and before I added the html it was echoeing the query results - so i know thats fine and working.

Personally i think its the way I have tried to insert the variables within the html code, but i thought this could be done like I have.

Can anyone see?

Please let me know if you need more information, database etc...

Thanks

<body>

<?php
$genre = $_GET['genre']; // retrieve passed variable
//open connection
$conn = mysql_connect("localhost", "admin", "adm1n");
mysql_select_db("project",$conn);

//$query = "SELECT ID_NO, F_NAME, F_DIRECTOR, F_REVIEWER, F_DATETIME, F_TYPE, F_SUMMARY, F_REVIEW, F_SCORE FROM films ORDER BY F_DATETIME LIMIT 1, 10 ";
//$query = "SELECT ID_NO, F_NAME, F_DIRECTOR, F_REVIEWER, F_DATETIME, F_TYPE, F_SUMMARY, F_REVIEW, F_SCORE FROM films ORDER BY F_DATETIME LIMIT 1, 10 ";
$query = "SELECT ID_NO, F_NAME, F_DIRECTOR, F_REVIEWER, F_DATETIME, F_TYPE, F_SUMMARY, F_REVIEW, F_SCORE FROM films WHERE F_TYPE LIKE '%$genre%' ORDER BY F_DATETIME LIMIT 1, 10 ";

$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$ID_NO = ($row['ID_NO']);
$F_NAME = ($row['F_NAME']);
$F_DIRECTOR = ($row['F_DIRECTOR']);
$F_REVIEWER = ($row['F_REVIEWER']);
$F_DATETIME = ($row['F_DATETIME']);
$F_TYPE = ($row['F_TYPE']);
$F_SUMMARY = ($row['F_SUMMARY']);
$F_REVIEW = ($row['F_REVIEW']);
$F_SCORE = ($row['F_SCORE']);

echo "Simon";
echo $genre;
?>
<table width="413" border="1" cellpadding="0" cellspacing="0" class="b">
                    <tr>
                      <td width="100" rowspan="3" valign="top"><img src="images/film/<?php $ID_NO ?>a.jpg" width="96" height="140" /></td>
                      <td width="227" height="29" valign="top">Film: <?php $F_NAME ?></td>
  <td width="86" valign="top"><a href=review.php?id=<?php $id_no ?>> read review </a> </td>
  </tr>
                    <tr>
                      <td height="31" valign="top">Director: <?php $F_DIRECTOR ?></td>
                    <td valign="top">Score: <?php F_SCORE ?> </td>
                    </tr>
                    <tr>
                      <td height="80" colspan="2" valign="top">Summary : <?php $F_SUMMARY ?> </td>
                    </tr>
                    <tr>
                      <td height="16" colspan="3" valign="top"><img src="images/siteGraphics/hr.jpg" width="413" height="11" alt="----------------------------------------------" /></td>
                    </tr>
                  </table>
<?php } 
?>


</body>

Ta

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 14 March 2006 - 08:12 PM

in each case where yu are trying to show the result in the html...

change <?php $XXX; ?>

to

<?php echo $XXX; ?>

where XXX is your variable....
follow me on twitter @PHPsycho

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 14 March 2006 - 09:00 PM

[!--quoteo(post=355035:date=Mar 14 2006, 03:12 PM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Mar 14 2006, 03:12 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
in each case where yu are trying to show the result in the html...

change <?php $XXX; ?>

to

<?php echo $XXX; ?>

where XXX is your variable....
[/quote]

or, simply use "<?= $XXX; ?>"
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users