$temp = 2;
         $query2 = mysql_query('SELECT * FROM mayballcomments WHERE postNo = "$temp"');
            while($result2 = mysql_fetch_array($query2)) { 

Hi, when I use a php variable in my mysql query, it keeps on being treated as 0, even though in this case its clearly 2. What am i doing wrong?

    Well you're using single quotes around the whole query meaning any variables won't be expanded, $temp will remain as exactly that, change it to

    $q = "SELECT * FROM mayballcomments WHERE postNo = '$temp'";
    

    You can even take the variable outside of the string, but read up on that elsewhere.

      lol, I just had a real "d'oh' moment there, cheers dude.

        Write a Reply...