Imtehbegginer Posted April 1, 2007 Share Posted April 1, 2007 <?php session_start(); include('inc/rosecms.php'); $rosecms_config = mysql_query("SELECT * FROM rosecms_config"); $rosecms_servers = mysql_query("SELECT * FROM rosecms_servers"); $rosecms = mysql_fetch_array($rosecms_config); $servers = mysql_fetch_array($rosecms_servers); ?> This: <?php echo $rosecms['logadmincp']; ?> Prints out NOTHING. This: <?php echo $servers['name']; ?> Does echo the right info. Any ideas? Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/ Share on other sites More sharing options...
yzerman Posted April 1, 2007 Share Posted April 1, 2007 try this: <?php session_start(); include('inc/rosecms.php'); $rosecms_config = mysql_query("SELECT * FROM rosecms_config"); $rosecms_servers = mysql_query("SELECT * FROM rosecms_servers"); $rosecms = mysql_fetch_array($rosecms_config); $servers = mysql_fetch_array($rosecms_servers); if (!$rosecms) { echo 'There was an error in your mysql query. The error returned was' . mysql_error($rosecms_config); } else { echo $rosecms; } ?> Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219404 Share on other sites More sharing options...
Imtehbegginer Posted April 1, 2007 Author Share Posted April 1, 2007 That echos "Array" but it wont echo the data in the table. echo $rosecms['allowreg'] should echo YES. It doesnt. Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219407 Share on other sites More sharing options...
yzerman Posted April 1, 2007 Share Posted April 1, 2007 The name in $rosecms['name'] should be exactly the field name. try this, and see if the names returned are the ones you are using: <?php session_start(); include('inc/rosecms.php'); $rosecms_config = mysql_query("SELECT * FROM rosecms_config"); $rosecms_servers = mysql_query("SELECT * FROM rosecms_servers"); $rosecms = mysql_fetch_array($rosecms_config); $servers = mysql_fetch_array($rosecms_servers); if (!$rosecms) { echo 'There was an error in your mysql query. The error returned was' . mysql_error($rosecms_config); } else { print_r($rosecms); } ?> Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219413 Share on other sites More sharing options...
Imtehbegginer Posted April 1, 2007 Author Share Posted April 1, 2007 Array ( [0] => md5reg [config] => md5reg [1] => 1246.8.. [value] => 1246.8.. ) That's what I get with that. Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219415 Share on other sites More sharing options...
yzerman Posted April 1, 2007 Share Posted April 1, 2007 so are the names returned the ones you are using? Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219416 Share on other sites More sharing options...
Imtehbegginer Posted April 1, 2007 Author Share Posted April 1, 2007 With my original code, the $servers['name'] was working fine. The $rosecms[]; wont. Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219418 Share on other sites More sharing options...
yzerman Posted April 1, 2007 Share Posted April 1, 2007 so are the names returned the ones you are using? What I am asking is: In the resulting array that was printed out: Array (* => md5reg [config] => md5reg [1] => 1246.8.. [value] => 1246.8.. [2]) Basically, $rosecms['config'] would echo md5reg, and so would $rosecms[1] My question to you is, you tried using $rosecms['logadmincp'] Does this value show up anywhere in the array that is printed out? Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219421 Share on other sites More sharing options...
Imtehbegginer Posted April 1, 2007 Author Share Posted April 1, 2007 No... it doesnt. Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219422 Share on other sites More sharing options...
yzerman Posted April 1, 2007 Share Posted April 1, 2007 Then thats why it will not return a value. Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219423 Share on other sites More sharing options...
spfoonnewb Posted April 1, 2007 Share Posted April 1, 2007 See what this says: <?php $rosecms_config = mysql_query("SELECT logadmincp FROM rosecms_config") or die(mysql_error()); $rosecms = mysql_fetch_array($rosecms_config); echo $rosecms['logadmincp']; ?> Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219425 Share on other sites More sharing options...
Imtehbegginer Posted April 1, 2007 Author Share Posted April 1, 2007 Unknown column 'logadmincp' in 'field list' - There's only 2 column's in "rosecms_config".... "config" and "value". Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219426 Share on other sites More sharing options...
spfoonnewb Posted April 1, 2007 Share Posted April 1, 2007 So which one has the value you want? Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219427 Share on other sites More sharing options...
yzerman Posted April 1, 2007 Share Posted April 1, 2007 Imthebeginner, The mysql_fetch_array function will return an array of the results, both numbered, and by the table field names they are pulled from if not specified. If the table does not contain a field named logadmincp, then that field will not be a valid mysql result, meaning you need to find out where your data is stored, and what the field name is that you want to echo. Link to comment https://forums.phpfreaks.com/topic/45194-mysql-fetch-array-wont-echo/#findComment-219428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.