Warning: mysql_fetch_assoc() expects parameter...

Status
Not open for further replies.

necm1

Member
Jan 27, 2014
111
16
Hello people,
I have been working today on a new CMS. And suddenly get some errors, I've had ever looked, and bit edited, but it still does not work:
Warning: mysql_fetch_assoc () expects parameter 1 to be resource, string givenName in / Applications / XAMPP / xamppfiles / htdocs / customer / app / controller / config.inc.php on line 17
Warning: Illegal string offset 'cms_maintenance' in / Applications / XAMPP / xamppfiles / htdocs / customer / app / controller / config.inc.php on line 23
Config.inc.php:
PHP:
<?php
/**
* Created by JetBrains PhpStorm.
* User: admin
* Date: 04.02.14
* Time: 22:34
* To change this template use File | Settings | File Templates.
*/
//Database config
$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "eclipse";
$mysql_database = "cms";
//Hotel settings
$sitename = "Oderuz";
$shortname = "Your CMS";
$server_status = mysql_fetch_assoc("SELECT * FROM server_status");
$server_query = mysql_query($server_status);
$users_online = $server_status['users_online'];
$rooms_loaded = $server_query['rooms_loaded'];
$hotel_status = $server_query['status'];
$cms = "SELECT * cms_settings";
$maintenance = $cms['cms_maintenance'];

So I spend the xd:
<?php echo $users_online; ?>
EIDT:
Had probably the mysql_query () had forgotten. But the problem is, he does not give me online users from.
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,396
960
Change $server_status['users_online']; to $server_query['users_online'];

Instead of:
$server_status = mysql_fetch_assoc("SELECT * FROM server_status");
$server_query = mysql_query($server_status);

You can just combine it:
$server_query = mysql_fetch_assoc(mysql_query("SELECT * FROM server_status"));

As for the cms part, you just have the select statement in a variable. You need to pass that through mysql_fetch_assoc(mysql_query()); first
 

necm1

Member
Jan 27, 2014
111
16
Change $server_status['users_online']; to $server_query['users_online'];

Instead of:
$server_status = mysql_fetch_assoc("SELECT * FROM server_status");
$server_query = mysql_query($server_status);

You can just combine it:
$server_query = mysql_fetch_assoc(mysql_query("SELECT * FROM server_status"));

As for the cms part, you just have the select statement in a variable. You need to pass that through mysql_fetch_assoc(mysql_query()); first
Thanks!
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Mysql_fetch_assoc/_array accepts a resource! not a string, so ecko's suggestion should work fine.

Btw, use mysqli
 
Status
Not open for further replies.

Users who are viewing this thread

Top