Crashdowngurl Posted May 2, 2006 Share Posted May 2, 2006 I've been working on this for hours and I can't find whats going wrong to save my life. I have a feeling this is one of those situations where I am going to feel dumb for not realizing the problem :) I know this is probably something to do with $_GET['id'] but I am unsure how to structure it.I am creating a page that will pull entries from a database and display a list of the enteries on the side of the page, when you click on one, it will display that entry's data. I am working doing this for my portfolio pieces for school, so each of my projects has a name that is supposed to call the id, title, type, image, description, and link from the database.The list of entries displays perfectly on the side, however, when I click on the them, no information all appears. I've attached the code below. Please help me![code]<?phperror_reporting(0);include $_Server['DOCUMENT_ROOT'].'includes/header.html';require('includes/database.php'); // What are we looking for? (Decide Query) $query = "UPDATE fbnet_portfolio WHERE id=1 SET count = count + 1"; // Store info in debug $debuginfo .= "COUNTER QUERY ".$query; $debugtotal=$debugtotal+1; // Update the counter table setting the total hits up by one mysql_query($query,$db); if (!isset($type) or $type=="") { $type="website"; } // Format if $id is not set or if it ="" then set it to "1" if (!isset($id) or $id=="") { $id="1"; } $result = mysql_query("SELECT id, title, type FROM portfolio WHERE type='website'"); while($result && list($id, $title, $type)=mysql_fetch_row($result)) { $portfoliolist .= "<a href=\"webdesign.php?id=" . $id . "\">" . $title . "</a><br />"; } // What are we looking for? (Decide Query) $query = "SELECT * FROM portfolio WHERE id=".$id; // Store info in debug $debuginfo .= "INFO QUERY ".$query; $debugtotal=$debugtotal+1; $result = mysql_query($query); //while ($myrow = mysql_fetch_row($result)) if ($myrow = @mysql_fetch_array($result)) { $title = $myrow[1]; $type = $myrow[2]; $image = $myrow[3]; $description = $myrow[4]; $link = $myrow[5]; } ?> [/code]I'm using the following to pull the information from the database:[code]<?PHP echo($title); ?> [/code] Like I said, the list is working fine, it's just when you click on the links, the information relative to the id number is not displaying.Any help with this would be EXTREMELY appreciated :)Thank you! -Emma Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/ Share on other sites More sharing options...
thenk83 Posted May 2, 2006 Share Posted May 2, 2006 [code] $query = "SELECT * FROM portfolio WHERE id=".$id;[/code]i think should be[code]$query = "SELECT * FROM portfolio WHERE id='$id'";[/code]Try that out see how it works. Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32728 Share on other sites More sharing options...
Crashdowngurl Posted May 2, 2006 Author Share Posted May 2, 2006 still the same :( Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32731 Share on other sites More sharing options...
ober Posted May 2, 2006 Share Posted May 2, 2006 I would suggest removing the error suppression ("@" symbol) to see if there are any errors with the query. Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32744 Share on other sites More sharing options...
Crashdowngurl Posted May 2, 2006 Author Share Posted May 2, 2006 [!--quoteo(post=370686:date=May 2 2006, 03:07 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 2 2006, 03:07 PM) [snapback]370686[/snapback][/div][div class=\'quotemain\'][!--quotec--]I would suggest removing the error suppression ("@" symbol) to see if there are any errors with the query.[/quote]I removed it and the page displays no errors. Any other thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32752 Share on other sites More sharing options...
thenk83 Posted May 2, 2006 Share Posted May 2, 2006 [!--quoteo(post=370694:date=May 2 2006, 01:32 PM:name=Crashdowngurl)--][div class=\'quotetop\']QUOTE(Crashdowngurl @ May 2 2006, 01:32 PM) [snapback]370694[/snapback][/div][div class=\'quotemain\'][!--quotec--]I removed it and the page displays no errors. Any other thoughts?[/quote]under [code]$result = mysql_query($query);[/code] Try[code]if(!$result){ echo mysql_error(); }[/code]That should give u a message. Hopefully! Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32767 Share on other sites More sharing options...
Crashdowngurl Posted May 2, 2006 Author Share Posted May 2, 2006 No message :( PHP hates me![code]$query = "SELECT * FROM portfolio WHERE id='$id'"; // Store info in debug $debuginfo .= "INFO QUERY ".$query; $debugtotal=$debugtotal+1; $result = mysql_query($query); if(!$result){ echo mysql_error(); }[/code]Thats how I added it in there, page still displays fine, but doesn't show any of the information. Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32772 Share on other sites More sharing options...
ansarka Posted May 3, 2006 Share Posted May 3, 2006 Plz change it to [b]// What are we looking for? (Decide Query)$query = "SELECT * FROM portfolio WHERE id='$id'";$result = mysql_query($query,$db);while ($myrow = mysql_fetch_row($result)){ $title = $myrow[1]; $type = $myrow[2]; $image = $myrow[3]; $description = $myrow[4]; $link = $myrow[5]; }[/b] Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32895 Share on other sites More sharing options...
umasankar Posted May 3, 2006 Share Posted May 3, 2006 Hi,First u have to check the $id value is a valued one or not.print the value of $id. ( echo $id).then .,1. print the query.2. copy the query and paste it into the PHYMYADMIN >> SQL section ( Because of first u have test the query passed is correct or not)3.still u have problem.4. make the query asSELECT * FROM portfolio WHERE id='.$_GET['id'].'";try this please.Umasankar Subramanian Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32928 Share on other sites More sharing options...
craygo Posted May 3, 2006 Share Posted May 3, 2006 First, as Subramanian said, $id is not even set yet. If you ar passing it thru the url, first thing at the top should be[code]$id = $_GET['id'];[/code]or use Subramanian's query.Without that you will never get anything including errors because your query is looking for a null or 0 id. This is perfectly fine for a query which is why you get no errors, and you get no results because the 0 or null id doesn't exist. Quote Link to comment https://forums.phpfreaks.com/topic/8912-information-not-pulling-from-database/#findComment-32931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.