Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

php error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

php error

Postby wijayabahu » Sun Mar 03, 2013 9:18 am

Code: Select all
<?php
  session_start();
 
 
  mysql_connect('localhost','root','') or die(mysql_error());
  mysql_select_db('sh_chart') or die(mysql_error());
 
 

function product(){
   $get =mysql_query('SELECT price FROM sh_chart WHERE price<10.00 ORDER BY DESC');
   echo mysql_num_rows($get);
       
}

?>


i have this error massage ( Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\shopingchart\chart.php on line 12)

Code: Select all
why wrong this code????

plz help me :(
wijayabahu
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Mar 03, 2013 9:08 am

Re: php error

Postby chrisranjana » Sun Mar 03, 2013 9:06 pm

can you check whether
Code: Select all
SELECT price FROM sh_chart WHERE price<10.00 ORDER BY DESC
works in an SQL prompt (like phpmyadmin etc)
chrisranjana
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Jun 24, 2012 4:32 pm
Location: Chennai India

Re: php error

Postby seandisanti » Mon Mar 04, 2013 10:26 am

A failed query (results in error) returns false. That could be because the connection failed, a column or table name is misspelled, etc. If you're not seeing sql error text on your screen, view source on the page that is returning that error and you should see the SQL error embedded inside of a tag. it will give you a better idea of what is actually wrong. Or just take the query as chrisranjana said and run it in mysql or phpmyadmin to get the error directly without having to view source. That will work for field or table level errors.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 783
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.