monkeypaw201 Posted February 8, 2008 Share Posted February 8, 2008 so, i am trying to run the following code: $pilot_id = mysql_connect("localhost","cerulean","bluesky1701"); if (!$pilot_id) { die('Could not connect: ' . mysql_error()); } mysql_select_db("cerulean_site", $pilot_id); $result = mysql_query("SELECT * FROM pilots ORDER BY pilot_id DESC"); $pilot_id=$row['pilot_id']; and its throwing a weird error about an undefined variable Notice: Undefined variable: row Quote Link to comment https://forums.phpfreaks.com/topic/90094-solved-undefined-varibale/ Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 You haven't defined the array $row anywhere. Ken Quote Link to comment https://forums.phpfreaks.com/topic/90094-solved-undefined-varibale/#findComment-461916 Share on other sites More sharing options...
monkeypaw201 Posted February 8, 2008 Author Share Posted February 8, 2008 but this is giving me the same error: $pilot_id = mysql_connect("localhost","cerulean","bluesky1701"); if (!$pilot_id) { die('Could not connect: ' . mysql_error()); } mysql_select_db("cerulean_site", $pilot_id); $result = mysql_query("SELECT * FROM pilots ORDER BY pilot_id DESC"); $pilot_id=$row_pilot_id['pilot_id']; Quote Link to comment https://forums.phpfreaks.com/topic/90094-solved-undefined-varibale/#findComment-461918 Share on other sites More sharing options...
Caesar Posted February 8, 2008 Share Posted February 8, 2008 What the above poster said. Maybe you forgot to grab the results from your query... <?php while($row = mysql_fetch_array($result)) { //Do what you've got to do. } ?> If you only want one record/row... <?php $row = mysql_fetch_array($result); ?> You are saying that "$pilot_id" equals something yuou have not defined. Quote Link to comment https://forums.phpfreaks.com/topic/90094-solved-undefined-varibale/#findComment-461922 Share on other sites More sharing options...
monkeypaw201 Posted February 8, 2008 Author Share Posted February 8, 2008 worked perfectly, thx Quote Link to comment https://forums.phpfreaks.com/topic/90094-solved-undefined-varibale/#findComment-461923 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.