php - Data not displaying -


i have link links page echoes out information depending on id of link not echoing out information. in advance help.

if($connect) {             mysql_selectdb('phplogin');             $id = $_get['id'];             $query = mysql_query("select * forum id = '$id'");             $data = mysql_fetch_array($query);             echo "<div class='post'>" . "<div class='leftside'>" . "<h3 class='by'>" . $data['user'] . "</h3>" . "<h5 class='date'>" . $data['time'] . "</h5>" . "</div>" . "<div class='after'>" . "</div>" . "<div class='rightside'>" . "<h2 class='title'>" . htmlspecialchars($data['title']) . "</h2>" . "<p class='description'>" . htmlspecialchars($data['description']) . "</p>"  . "</div>" . "<div class='clear'>" . "</div>" . "</div>";          } else {             die ('failed connect database');         } 

under query string: localhost/website/html/post.php?id=7

try this:

if(isset($_get['id'])) {      $id       = $_get['id'];      $query    = mysql_query("select * forum id = '$id'");      $countqry = mysql_num_rows($query);      if($countqry>0)      {           $data     = mysql_fetch_array($query);           //-- fetch data here ---//      }      else      {           echo "no record found.";      } } else {      echo "invalid id"; } 

your mysql connection should :

<?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) {     die('could not connect: ' . mysql_error()); } echo 'connected successfully'; mysql_close($link); ?> 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -