Bruisedghost Posted August 7, 2009 Share Posted August 7, 2009 Im banging my head against the wall on this one. Im almost positive I have my array setup properly but Im getting this error Notice: Use of undefined constant type - assumed 'type' in C:\wamp\www\test\test.php on line 22 Notice: Use of undefined constant Model - assumed 'Model' in C:\wamp\www\test\test.php on line 23 Notice: Use of undefined constant purchased - assumed 'purchased' in C:\wamp\www\test\test.php on line 24 Notice: Use of undefined constant stats - assumed 'stats' in C:\wamp\www\test\test.php on line 25 Dell LX 4700 Here is the code it is referring to: ..ommitted the db select vars.. $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); mysql_select_db($db) or die ("Unable to select database!"); // create queries will select all data in database and display it as listed $queryn = "SELECT type, Model, purchased, purchaser, stats FROM hardware"; $result = mysql_query($queryn) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { //begin while loop while($row = mysql_fetch_assoc($result)) { //set image variables $one = $row[type]; $two = $row[Model]; $three = $row[purchased]; $four = $row[stats]; /* echo image table for testing only! ommit this line if images ar enot showing up, if the images dont show up after omission then there is an error with the MySQL database and or connection */ // THIS IS WHAT IS DISPLAYED ON THE WEBSITE echo $one.$two.$three.$four; /*****************************************/ } } else { // no // print status message echo "Sorry fella, nothing left"; } // free result set memory mysql_free_result($result); ?> any help on this would be greatly appreciated! Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/169240-notice-use-of-undefined-constant/ Share on other sites More sharing options...
Maq Posted August 7, 2009 Share Posted August 7, 2009 You need single quotes around the keys in your associative arrays. Quote Link to comment https://forums.phpfreaks.com/topic/169240-notice-use-of-undefined-constant/#findComment-893032 Share on other sites More sharing options...
Bruisedghost Posted August 7, 2009 Author Share Posted August 7, 2009 You need single quotes around the keys in your associative arrays. My hero, thanks so much :D :D Quote Link to comment https://forums.phpfreaks.com/topic/169240-notice-use-of-undefined-constant/#findComment-893041 Share on other sites More sharing options...
Maq Posted August 7, 2009 Share Posted August 7, 2009 You need single quotes around the keys in your associative arrays. My hero, thanks so much :D :D NP. Be sure to mark as solved. Quote Link to comment https://forums.phpfreaks.com/topic/169240-notice-use-of-undefined-constant/#findComment-893052 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.