Vivid Lust Posted November 29, 2007 Share Posted November 29, 2007 This is my PHP: <?php @mysql_select_db( "inf_1235727_test", $conn ) or die( "could not select database" ); //stuff @mysql_query( "SELECT id FROM topics WHERE id = '$_GET['id']'" ) or die( "could not select query" ); ?> Working... The last MySQL Query doesnt work. Help please! Quote Link to comment Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 Remove your DB Name/PW from your post Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 29, 2007 Share Posted November 29, 2007 I see a problem with it, but why are you suppressing the error with the @? Change it to this mysql_query( "SELECT id FROM topics WHERE id = '{$_GET['id']}'" ) or die(mysql_error()); EDIT: Also, it doesn't do you much good if you don't assign it to a variable. $query = mysql_query( "SELECT id FROM topics WHERE id = '{$_GET['id']}'" ) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted November 29, 2007 Author Share Posted November 29, 2007 ooops Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted November 29, 2007 Author Share Posted November 29, 2007 It works thanks Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted November 29, 2007 Author Share Posted November 29, 2007 Ok so how could i echo fields on that "id" row??? Thanks Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 29, 2007 Share Posted November 29, 2007 <?php $query = mysql_query( "SELECT id FROM topics WHERE id = '{$_GET['id']}'" ) or die(mysql_error()); $row = mysql_fetch_assoc($query); echo $row['id']; ?> If you expecting more than one result, then use a while loop <?php $query = mysql_query( "SELECT id FROM topics WHERE id = '{$_GET['id']}'" ) or die(mysql_error()); while ($row = mysql_fetch_assoc($query)){ echo $row['id'].'<br>'; } ?> Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted November 29, 2007 Author Share Posted November 29, 2007 It sort of works i have a table like: id title text 1 BLAH BLAH 2 BLAH BLAH how can using the php GET also get the rest of the row? the loop thingy doesnt do it Quote Link to comment Share on other sites More sharing options...
revraz Posted November 29, 2007 Share Posted November 29, 2007 Thats because you are only selecting id FROM topics. If you want more, you have to SELECT more. Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted November 29, 2007 Author Share Posted November 29, 2007 ok Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted November 29, 2007 Share Posted November 29, 2007 DON'T USE INCOMING CLIENT PROVIDED INFORMATION WITH OUT SANITIZING IT FIRST! The SQL statment you are using is easily hacked. Please read about mysql_real_escape_string() http://us.php.net/mysql_real_escape_string 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.