Jump to content

[SOLVED] why does this not work


webmazter

Recommended Posts

Below is my 1st attempt to parse data from a mysql database.

i was able to post data from a input form, however now i cannot figure out why i cannot read the data i just posted.

im sure its a simple explaination

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Fish Database</title>

</head>

 

<body>

<?php

$con =    MYSQL_CONNECT('localhost', 'fishdbs_fishdb', 'fishdb') or die(MYSQL_ERROR());

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }mysql_select_db("fishdbs_fishdb", $con);

  $scientificname = "s";

  $query = MYSQL_QUERY("SELECT * FROM `fish` WHERE `scientificname`='$scientificname' LIMIT 1");

  ?>

 

<div align="center">

  <table width="489" height="756" border="0" cellpadding="0" cellspacing="1">

    <tr>

      <td height="179" colspan="4"><?= $query['photo']; ?></td>

    </tr>

    <tr>

      <td width="23%">scientificname:</td>

      <td width="18%"><?= $query['scientificname']; ?></td>

      <td width="29%">commonnames:</td>

      <td><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>size:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>lifespan:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>tanksize:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>ph:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>temperature:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>specificgravity:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>dkh:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>origin:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>temperament:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>compatability:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>diet:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>breeding:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>tankregion:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>gender:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

    <tr>

      <td>details:</td>

      <td colspan="3"><?= $query['scientificname']; ?></td>

    </tr>

  </table>

</div>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/
Share on other sites

I get this error now.

Parse error: syntax error, unexpected '<' in /home/fishdbs/public_html/fishdb.php on line 26

 

from adding this line

 

<td width="23%">scientificname:</td>

      <td width="18%"><? while($row=mysql_fetch_assoc($query)){<td colspan="3"><?php echo ".$row['scientificname']."; ?> </td>

 

 

 

fogot while loop plus ur using =? asp short tag use defult ?>........

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Fish Database</title>
</head>

<body>
<?php
$con =     MYSQL_CONNECT('localhost', 'fishdbs_fishdb', 'fishdb') or die(MYSQL_ERROR());
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("fishdbs_fishdb", $con);
  $scientificname = "s";
  $query = MYSQL_QUERY("SELECT * FROM `fish` WHERE `scientificname`='$scientificname' LIMIT 1");
  while($row=mysql_fetch_assoc($query)){
  ?>

<div align="center">
  <table width="489" height="756" border="0" cellpadding="0" cellspacing="1">
    <tr>
      <td height="179" colspan="4"><?php echo $query['photo']; ?></td>
    </tr>
    <tr>
      <td width="23%">scientificname:</td>
      <td width="18%"><?php echo $query['scientificname']; ?></td>
      <td width="29%">commonnames:</td>
      <td><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>size:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>lifespan:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>tanksize:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>ph:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>temperature:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>specificgravity:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>dkh:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>origin:</td>
      <td colspan="3"><?php  echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>temperament:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>compatability:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>diet:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>breeding:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>tankregion:</td>
      <td colspan="3"><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>gender:</td>
      <td colspan="3"><?php echo $query['scientificname'];?></td>
    </tr>
    <tr>
      <td>details:</td>
      <td colspan="3"><?php echo $row['scientificname']; ?></td>
    </tr>
  </table>
  <?php }?>
</div>
</body>
</html>

http://fishdb.shellxnet.com/fishdb2.php

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Fish Database</title>
</head>

<body>
<?php
$con =     MYSQL_CONNECT('localhost', 'fishdbs_fishdb', 'fishdb') or die(MYSQL_ERROR());
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("fishdbs_fishdb", $con);
  $scientificname = "s";
  $query = MYSQL_QUERY("SELECT * FROM `fish` WHERE `scientificname`='$scientificname' LIMIT 1");
  while($row=mysql_fetch_assoc($query)){
  ?>

<div align="center">
  <table width="489" height="756" border="0" cellpadding="0" cellspacing="1">
    <tr>
      <td height="179" colspan="4"><?php echo $query['photo']; ?></td>
    </tr>
    <tr>
      <td width="23%">scientificname:</td>
      <td width="18%"><?php echo $query['scientificname']; ?></td>
      <td width="29%">commonnames:</td>
      <td><?php echo $query['scientificname']; ?></td>
    </tr>
    <tr>
      <td>size:</td>
      <td colspan="3"><?php echo $query['size']; ?></td>
    </tr>
    <tr>
      <td>lifespan:</td>
      <td colspan="3"><?php echo $query['lifespan']; ?></td>
    </tr>
    <tr>
      <td>tanksize:</td>
      <td colspan="3"><?php echo $query['tanksize']; ?></td>
    </tr>
    <tr>
      <td>ph:</td>
      <td colspan="3"><?php echo $query['ph']; ?></td>
    </tr>
    <tr>
      <td>temperature:</td>
      <td colspan="3"><?php echo $query['temperature']; ?></td>
    </tr>
    <tr>
      <td>specificgravity:</td>
      <td colspan="3"><?php echo $query['specificgravity']; ?></td>
    </tr>
    <tr>
      <td>dkh:</td>
      <td colspan="3"><?php echo $query['dkh']; ?></td>
    </tr>
    <tr>
      <td>origin:</td>
      <td colspan="3"><?php  echo $query['origin']; ?></td>
    </tr>
    <tr>
      <td>temperament:</td>
      <td colspan="3"><?php echo $query['temperament']; ?></td>
    </tr>
    <tr>
      <td>compatability:</td>
      <td colspan="3"><?php echo $query['compatiblity']; ?></td>
    </tr>
    <tr>
      <td>diet:</td>
      <td colspan="3"><?php echo $query['diet']; ?></td>
    </tr>
    <tr>
      <td>breeding:</td>
      <td colspan="3"><?php echo $query['breeding']; ?></td>
    </tr>
    <tr>
      <td>tankregion:</td>
      <td colspan="3"><?php echo $query['tanregion']; ?></td>
    </tr>
    <tr>
      <td>gender:</td>
      <td colspan="3"><?php echo $query['gender'];?></td>
    </tr>
    <tr>
      <td>details:</td>
      <td colspan="3"><?php echo $row['details']; ?></td>
    </tr>
  </table>
  <?php }?>
</div>
</body>
</html>

One error.

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/fishdbs/public_html/fishdb2.php on line 17

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Fish Database</title>
</head>

<body>
<?php
$con =     MYSQL_CONNECT('localhost', 'fishdbs_fishdb', 'fishdb') or die(MYSQL_ERROR());
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("fishdbs_fishdb", $con);
  $scientificname = "s";
  $row = MYSQL_QUERY("SELECT * FROM `fish` WHERE `scientificname`='$scientificname' LIMIT 1");
  while($row=mysql_fetch_assoc($row)){
  ?>

<div align="center">
  <table width="489" height="756" border="0" cellpadding="0" cellspacing="1">
    <tr>
      <td height="179" colspan="4"><?php echo $row['photo']; ?></td>
    </tr>
    <tr>
      <td width="23%">scientificname:</td>
      <td width="18%"><?php echo $row['scientificname']; ?></td>
      <td width="29%">commonnames:</td>
      <td><?php echo $row['scientificname']; ?></td>
    </tr>
    <tr>
      <td>size:</td>
      <td colspan="3"><?php echo $row['size']; ?></td>
    </tr>
    <tr>
      <td>lifespan:</td>
      <td colspan="3"><?php echo $row['lifespan']; ?></td>
    </tr>
    <tr>
      <td>tanksize:</td>
      <td colspan="3"><?php echo $row['tanksize']; ?></td>
    </tr>
    <tr>
      <td>ph:</td>
      <td colspan="3"><?php echo $row['ph']; ?></td>
    </tr>
    <tr>
      <td>temperature:</td>
      <td colspan="3"><?php echo $row['temperature']; ?></td>
    </tr>
    <tr>
      <td>specificgravity:</td>
      <td colspan="3"><?php echo $row['specificgravity']; ?></td>
    </tr>
    <tr>
      <td>dkh:</td>
      <td colspan="3"><?php echo $row['dkh']; ?></td>
    </tr>
    <tr>
      <td>origin:</td>
      <td colspan="3"><?php  echo $row['origin']; ?></td>
    </tr>
    <tr>
      <td>temperament:</td>
      <td colspan="3"><?php echo $row['temperament']; ?></td>
    </tr>
    <tr>
      <td>compatability:</td>
      <td colspan="3"><?php echo $row['compatiblity']; ?></td>
    </tr>
    <tr>
      <td>diet:</td>
      <td colspan="3"><?php echo $row['diet']; ?></td>
    </tr>
    <tr>
      <td>breeding:</td>
      <td colspan="3"><?php echo $row['breeding']; ?></td>
    </tr>
    <tr>
      <td>tankregion:</td>
      <td colspan="3"><?php echo $row['tanregion']; ?></td>
    </tr>
    <tr>
      <td>gender:</td>
      <td colspan="3"><?php echo $row['gender'];?></td>
    </tr>
    <tr>
      <td>details:</td>
      <td colspan="3"><?php echo $row['details']; ?></td>
    </tr>
  </table>
  <?php }?>
</div>
</body>
</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Fish Database</title>
</head>

<body>
<?php
$con =     MYSQL_CONNECT('localhost', 'fishdbs_fishdb', 'fishdb') or die(MYSQL_ERROR());
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("fishdbs_fishdb", $con);
  $scientificname = "s";
  $query = MYSQL_QUERY("SELECT * FROM `fish` WHERE `scientificname`='$scientificname' LIMIT 1");
  while($row=mysql_fetch_assoc($query)){
  ?>

<div align="center">
  <table width="489" height="756" border="0" cellpadding="0" cellspacing="1">
    <tr>
      <td height="179" colspan="4"><?php echo $row['photo']; ?></td>
    </tr>
    <tr>
      <td width="23%">scientificname:</td>
      <td width="18%"><?php echo $row['scientificname']; ?></td>
      <td width="29%">commonnames:</td>
      <td><?php echo $row['scientificname']; ?></td>
    </tr>
    <tr>
      <td>size:</td>
      <td colspan="3"><?php echo $row['size']; ?></td>
    </tr>
    <tr>
      <td>lifespan:</td>
      <td colspan="3"><?php echo $row['lifespan']; ?></td>
    </tr>
    <tr>
      <td>tanksize:</td>
      <td colspan="3"><?php echo $row['tanksize']; ?></td>
    </tr>
    <tr>
      <td>ph:</td>
      <td colspan="3"><?php echo $row['ph']; ?></td>
    </tr>
    <tr>
      <td>temperature:</td>
      <td colspan="3"><?php echo $row['temperature']; ?></td>
    </tr>
    <tr>
      <td>specificgravity:</td>
      <td colspan="3"><?php echo $row['specificgravity']; ?></td>
    </tr>
    <tr>
      <td>dkh:</td>
      <td colspan="3"><?php echo $row['dkh']; ?></td>
    </tr>
    <tr>
      <td>origin:</td>
      <td colspan="3"><?php  echo $row['origin']; ?></td>
    </tr>
    <tr>
      <td>temperament:</td>
      <td colspan="3"><?php echo $row['temperament']; ?></td>
    </tr>
    <tr>
      <td>compatability:</td>
      <td colspan="3"><?php echo $row['compatiblity']; ?></td>
    </tr>
    <tr>
      <td>diet:</td>
      <td colspan="3"><?php echo $row['diet']; ?></td>
    </tr>
    <tr>
      <td>breeding:</td>
      <td colspan="3"><?php echo $row['breeding']; ?></td>
    </tr>
    <tr>
      <td>tankregion:</td>
      <td colspan="3"><?php echo $row['tanregion']; ?></td>
    </tr>
    <tr>
      <td>gender:</td>
      <td colspan="3"><?php echo $row['gender'];?></td>
    </tr>
    <tr>
      <td>details:</td>
      <td colspan="3"><?php echo $row['details']; ?></td>
    </tr>
  </table>
  <?php }?>
</div>
</body>
</html>

Perfect.

i will offer you a small reward of a free cpanel account on my server if you can assist with one last thing.

http://www.dot.com/fish.db?scientificname

is what i would like to use instead of

$scientificname = "s";

 

if u can do this for me reply to me via [email protected] for your free cpanel account.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.