webmazter Posted May 26, 2008 Share Posted May 26, 2008 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 More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 IGNORE THIS POST PLEASE SORRY.... everyone chap while($row=mysql_fetch_assoc($query)){ << no while loop mate........ <td colspan="3"><?php echo ".$row['scientificname']."; ?></td> Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549884 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 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 https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549890 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 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 https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549891 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 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 https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549906 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 As shown above it does not work 100% yet, but at least no errors. Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549907 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 change all $query to $row sorry.... Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549909 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 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 https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549915 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 <!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 https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549917 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 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. Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549925 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 you want all the >>s<< to be links correct with a ?id=whatever yes...... Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549931 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 where the form your clicking to get current fish...... post it i got you Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549936 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 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 https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549937 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 http://fishdb.shellxnet.com/form2.php Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549938 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 but is s the fish name Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549939 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 In that case yes You can use Puffer http://fishdb.shellxnet.com/puffer.php Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549942 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 in the database what you calling the fish as the name example fishname=puffer Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549947 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 $scientificname = "Puffer"; Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549948 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 if you change the name at the end off the url do you see the correct diffrent fish detail try http://fishdb.shellxnet.com/puffer.php?scientificname=puffer Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549950 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 no i have tried with http://fishdb.shellxnet.com/puffer.php?scientificname=s and nothing see pm for ftp infomation to access pages. Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549953 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 I have tested with this url http://fishdb.shellxnet.com/urltest.php?scientificname=Puffer to remove the $scientificname = "Puffer"; from the code and no luck Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549956 Share on other sites More sharing options...
redarrow Posted May 26, 2008 Share Posted May 26, 2008 first we need a page to select the fish via there name Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549959 Share on other sites More sharing options...
webmazter Posted May 26, 2008 Author Share Posted May 26, 2008 If your willing to create it my offer still stands for free cpanel for a small site. Link to comment https://forums.phpfreaks.com/topic/107247-solved-why-does-this-not-work/#findComment-549960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.