Jump to content

Recommended Posts

this coding is working in localhost

<?php
 include("include/connection.php");
 
 
 $profile= mysql_query("SELECT count( user )FROM (SELECT user FROM computerrepair UNION ALL SELECT user FROM computersale UNION ALL SELECT user FROM hospital UNION ALL SELECT user FROM hotel UNION ALL SELECT user FROM house UNION ALL SELECT user FROM land UNION ALL SELECT user FROM mobile
UNION ALL SELECT user FROM theater UNION ALL SELECT user FROM upload UNION ALL SELECT user FROM vechicle) AS a
WHERE user = '$login_session'",$conn);
$menus=mysql_fetch_assoc($profile);
$noof=$menus['count( user )'];

 ?> 

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/a8326388/public_html/profile.php on line 59

 

$menus=mysql_fetch_assoc($profile); is in line 59

I think you'll need to check to make sure that the result set is not empty before calling that function. Normally though the error will also include "boolean given" (false).

 

So try this:

 

if( empty( $profile ) ){
  echo 'No results found';
}else{
  //do whatever here with your results
}

 

As requinix said it could be to do with your connection in the include. Although I'd expect it to fail on mysql_query. Sorry for my uncertainty I'm used to PDO.

Edited by exeTrix

I think you'll need to check to make sure that the result set is not empty before calling that function. Normally though the error will also include "boolean given" (false).

 

So try this:

 

 

if( empty( $profile ) ){
  echo 'No results found';
}else{
  //do whatever here with your results
}

 

 

As long as the query worked, $profile will be set to something. empty($profile) won't tell you if there were any results, and you won't get an error trying to fetch from a (successful) resultset even if it's empty.

I think you'll need to check to make sure that the result set is not empty before calling that function. Normally though the error will also include "boolean given" (false).

 

So try this:

 

if( empty( $profile ) ){
  echo 'No results found';
}else{
  //do whatever here with your results
}

 

As requinix said it could be to do with your connection in the include. Although I'd expect it to fail on mysql_query. Sorry for my uncertainty I'm used to PDO.

 

this coding is not counting but it working localhost

 

<?php
 include("include/connection.php");
 
 
 $profile= mysql_query("SELECT count( user )FROM (SELECT user FROM computerrepair UNION ALL SELECT user FROM computersale UNION ALL SELECT user FROM hospital UNION ALL SELECT user FROM hotel UNION ALL SELECT user FROM house UNION ALL SELECT user FROM land UNION ALL SELECT user FROM mobile
UNION ALL SELECT user FROM theater UNION ALL SELECT user FROM upload UNION ALL SELECT user FROM vechicle) AS a
WHERE user = '$login_session'",$conn);

if( $profile  ){
      $menus=mysql_fetch_assoc($profile);
$noof=$menus['count( user )'];
 
}else{
  //do whatever here with your results
$noof= '0';
}

 ?>
Edited by Spraban9

 

Error

SQL query: b_help.png

SELECT count( user )
FROM (

SELECT user
FROM computerrepair
UNION ALL SELECT user
FROM computersale
UNION ALL SELECT user
FROM hospital
UNION ALL SELECT user
FROM hotel
UNION ALL SELECT user
FROM house
UNION ALL SELECT user
FROM land
UNION ALL SELECT user
FROM mobile
UNION ALL SELECT user
FROM theater
UNION ALL SELECT user
FROM upload
UNION ALL SELECT user
FROM vechicle
) AS a
WHERE user = 'mathu'

MySQL said: b_help.png
#1054 - Unknown column 'user' in 'field list'

same database like the localhost have

but in 000webhost phpmyadmin display this error to this query

Edited by Spraban9
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.