dudejma Posted June 21, 2011 Share Posted June 21, 2011 <?php require "db_connect.php"; $current_db = mysql_select_db('virtu857_va'); if (!$current_db) { die("Could not select database because: " . mysql_error()); } $pilotnum = "SELECT max(pilotnum) FROM users"; $result = mysql_query($pilotnum); if (!$result) { die("Error: " . mysql_error()); } echo $pilotnum; ++$pilotnum; echo $pilotnum; ?> Everytime I try to run this code, this is what comes up: SELECT max(pilotnum) FROM usersSELECT max(pilotnum) FROM usert What's wrong? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/239964-code-not-working/ Share on other sites More sharing options...
Alex Posted June 21, 2011 Share Posted June 21, 2011 You're never getting the data from the result. You need to do something like this: $result = mysql_query($pilotnum); $row = mysql_fetch_assoc($result); echo $row['max(pilotnum)']; Instead of echoing the query. Quote Link to comment https://forums.phpfreaks.com/topic/239964-code-not-working/#findComment-1232663 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.