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

}

?>

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.