Aureole Posted July 26, 2007 Share Posted July 26, 2007 Real quick question. On my news page I have a link to the full story and then the short story below. The link to the full story is news/viewfull.php?id=something Now what I need to do is make it so if the id=5 in the url it will query the database and get the fullstory that has an id of 5. Does that make sense? Is it something like... <?php if (isset($_GET['id'])) { $theid = $_GET['id']; $query = "SELECT fullstory FROM news WHERE id=$theid"; // Etc.... ?> // Connect to db etc. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 ya Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted July 26, 2007 Share Posted July 26, 2007 Yes, But for future reference make sure to put quotes '' like here in ur query: <?php if (isset($_GET['id'])) { $theid = $_GET['id']; $query = "SELECT fullstory FROM news WHERE id='$theid'"; // Etc.... ?> Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 I have this and it isn't working... <?php if (isset($_GET['id'])) { $theid = $_GET['id']; DEFINE ('DB_USER', '********'); DEFINE ('DB_PASSWORD', '********'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', '********'); $connectme = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error()); @mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error() ); $query = "SELECT full FROM news WHERE id='$theid'"; $result = @mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "{row['full']}"; } } ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 echo "{row['full']}"; look row['full'] no dollar sign it should be $row['full'] or is there another error Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 I'm sorry I should have checked the code more carefully...thanks a lot for your help. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 dude i dont understand why all of a sudden i see this @@@@@ its like your expecting that there will be an error or you are saying that the code you made is not reliable Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Author Share Posted July 26, 2007 I'm new to PHP, take it easy on me... @ hides errors right? Well the first tutorial I read said it's always best to add @ ...so it's a habit I guess...anyway calm down lol, the code I make isn't reliable and I do expect errors, I'm new. Quote Link to comment 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.