Jump to content

MySQL Fetch Array wont echo?


Imtehbegginer

Recommended Posts

<?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

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;

}

?>

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);
}
?>

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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.