php - MySQL Syntax for Where clause -


im not in php. have web application displays data mysql database. not getting erros need fetch data want.

ex. code.

<?php $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); $token = $_get['token'];  if(! $conn )   {     die('could not connect: ' . mysql_error());   } $sql = "select * table token = '" . $token . "'";  mysql_select_db('database'); $retval = mysql_query( $sql, $conn ); if(! $retval )   {     die('could not data: ' . mysql_error());   }   while($row = mysql_fetch_array($retval, mysql_assoc))    {      //displays data    echo "the token here";    }    mysql_close($conn);   ?> 

i have no errors in here. need like, if token data not yet added table, put echo message like.. "the token not yet added here". can put syntax here? please me. new in php.

use this:

 if(mysql_num_rows($retval)) {      while($row = mysql_fetch_array($retval, mysql_assoc))      {       //displays data       echo "the token here";      }    } else {      echo "the token not yet added here";    } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -