RE: [PHP] SQL statement

From: Date: Wed, 24 Sep 2003 00:56:45 +0000
Subject: RE: [PHP] SQL statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-163677@lists.php.net to get a copy of this message
> Thank you for your time on this. No problem. > > <?php > // Function that runs reports on logon history > > function logonHist() { > > db_connect(); //establish connection > > $_qlogonhist = ("SELECT username,host_info,status, DATE_FORMAT(timestamp, > '%d%m%y') > as formatted_ts FROM custlogon_hist"); // Build query. > //$_qlogonhist = ('SELECT * FROM custlogon_hist'); > $_rlogonhist = mysql_query($_qlogonhist) or die(mysql_error()); > For testing purposes add or die(mysql_error()) to your code as I have above. That way we can see if the error is in the query. > > <?php echo $row['timestamp'];?></font></td>?> > > Notice: Undefined index: timestamp in C:\Program Files\Apache > Group\Apache2\htdocs\Ameriforms\admintool\includes\getlogonhist.ph > p on line > 44 timestamp is still undefined, we aliased the column to formatted_ts, so formatted_ts is the array index. I did this because I'm not certain you can use a column name that already exist as an alias becuase mySQL likes unique aliases and I didn't feel like looking up whether or not we could use 'timestamp'

« previous php.general (#163677) next »