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. Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/ Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 ya Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307640 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.... ?> Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307641 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']}"; } } ?> Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307642 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 Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307644 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. Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307645 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 Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307650 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. Link to comment https://forums.phpfreaks.com/topic/61785-solved-pass-an-id-to-another-file-quick-question/#findComment-307657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.