Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2012, 01:34 PM   PM User | #1
zodehala
Regular Coder

 
Join Date: Dec 2007
Posts: 269
Thanks: 28
Thanked 0 Times in 0 Posts
zodehala can only hope to improve
mysql_num_rows problem

PHP Code:
$link mysql_connect("localhost""root""123");
mysql_select_db("db"$link);
        
$result     mysql_query("SELECT * FROM kul WHERE kuladi = root");
if(
mysql_num_rows($result)!=1){
    echo 
"no user";


gives following error. why?
Code:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\tekoser\x.php on line 6
zodehala is offline   Reply With Quote
Old 01-10-2012, 01:40 PM   PM User | #2
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
It's because your query is throwing an error and you're not catching it. wrap root in ' to define it as a string.

Use or die() statements or something else to catch mysql errors.

Also, you've just told the world your database root password. Remember to censor sensitive information when posting here.
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Old 01-10-2012, 02:02 PM   PM User | #3
zodehala
Regular Coder

 
Join Date: Dec 2007
Posts: 269
Thanks: 28
Thanked 0 Times in 0 Posts
zodehala can only hope to improve
db user root and pass123

user ind db is root and his pass is 123
zodehala is offline   Reply With Quote
Old 01-10-2012, 02:05 PM   PM User | #4
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Quote:
Originally Posted by zodehala View Post
db user root and pass123

user ind db is root and his pass is 123
What? That's completely unrelated to my answer.
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Old 01-10-2012, 02:08 PM   PM User | #5
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
You edited your post as I replied. The user for the database is (and definitely should be) different from users stored in the database.

You're telling us your database user and pass! These forums are open to the public!

Your problem is in your sql query - a syntax error like I said.
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Old 01-10-2012, 09:10 PM   PM User | #6
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,505
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by BluePanther View Post
You edited your post as I replied.
I'm not seeing the traditional "Last edited.." line anywhere
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 01-10-2012, 09:14 PM   PM User | #7
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Quote:
Originally Posted by tangoforce View Post
I'm not seeing the traditional "Last edited.." line anywhere
It doesn't appear if you edit within a certain time frame
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 AM.


Advertisement
Log in to turn off these ads.