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
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>

 

 

 

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

<!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>

Link to comment
Share on other sites

More like i want to have many fish in the database and have it call each fish by the name with the url instead of the function listed in the html

 $scientificname = "Puffer";

 

www.dot.com/fish?puffer

www.dot.com/fish?angel

 

etc

 

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.