MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 16th, 2003, 05:55 PM
Cpaulv Cpaulv is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 Cpaulv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mysql_num_rows(...) problem

i'm getting this error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Apache\htdocs\phpform\forms\process.php on line 40

and line 40 is: if(mysql_num_rows($check) > 0)
line 41: {
line 42: $error.="The username you have chosen is already being used, please go back and choose another one.";
line 43: }

i'm not sure what is going wrong.

Reply With Quote
  #2  
Old May 16th, 2003, 09:44 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Quote:
i'm not sure what is going wrong.

It's in your query - not num_rows. You need to show the query to get any help...

Also - you should get rid of the comparison, comparisons are slow. Change your num rows to:
PHP Code:
if ( mysql_num_rows$check ) ) 

If 0 (zero) rows are returned - that would evaluated to false. If 1 (one) or more rows are returned, it would eval to true...
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old May 16th, 2003, 10:14 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
when you execute

$check = mysql_query(...);

call

echo mysql_error();

directly underneath it, to echo out the error

Reply With Quote
  #4  
Old May 16th, 2003, 11:11 PM
Cpaulv Cpaulv is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 Cpaulv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here is what i have for this bit of code:

$check = mysql_query("$Username");

call

echo mysql_error(); (this is line 42, and the stuff in this brackets is not in the code)
echo "Please choose another username.";

the error i get is:

Parse error: parse error, unexpected T_ECHO in C:\Apache\htdocs\phpform\forms\process.php on line 42

see i'm a total noob at php coding so i'll need some help, thx.

Reply With Quote
  #5  
Old May 17th, 2003, 10:03 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
firstly, could you show us what $username has in it?

then you should have something like this:

$username = "SELECT * FROM users WHERE username = '$username'";

$check = @mysql_query($username);

echo mysql_error();

if(@mysql_num_rows($check) > 0) {

echo "message here";

}

Reply With Quote
  #6  
Old May 17th, 2003, 11:13 PM
Cpaulv Cpaulv is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 Cpaulv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the database table is called information and whatever you call the suttf inside it, one of them is called username

Reply With Quote
  #7  
Old May 18th, 2003, 01:53 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
could you please send us the query,

just echo out $username before you run the query and paste it here, as it would help us diagonse your problem

Reply With Quote
  #8  
Old May 18th, 2003, 06:11 PM
Cpaulv Cpaulv is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 Cpaulv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well everything looks ok, i just miss spelled some words and reversed a couple brackets, but now i need to chose a database which i have no clue how to do.

Reply With Quote
  #9  
Old May 21st, 2003, 06:25 AM
Cpaulv Cpaulv is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 Cpaulv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
can anyone pass me a link where i can find out how to log into a database and use it? (like what i needed for my last post)

Reply With Quote
  #10  
Old May 21st, 2003, 10:05 AM
picker999 picker999 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 19 picker999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to picker999 Send a message via AIM to picker999
Odd

Its odd that you would need info on the query before you chose your database. Are you getting this forum to do your homework for you?

Reply With Quote
  #11  
Old May 21st, 2003, 03:13 PM
Cpaulv Cpaulv is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 Cpaulv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this isn't homework buddy, its for a signup form i need for a future business (future being the key word), i've been really busy lately and haven't been able to look around for info about it. also it gave me those errors before the database problem, also i don't know php coding for anything so i don't know what i need what goes before what or anything, i just know how to use it.

Reply With Quote
  #12  
Old May 21st, 2003, 05:39 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Cool

PHP Code:
/*database connection*/
     
$mysqlcon=mysql_connect ('localhost','username','pass') or die('could not connect to server: '.mysql_error());
     
$db=mysql_select_db('databse_name',$mysqlcon) or die('could not select database '.mysql_error()); 

This has to be done before you query the db. If you have to querey the db alot I sugest you make it into a class file and require it on the subsequent pages cause it will save you typing it on all the subsequent pages
__________________
CHornJr
"One day I'll know what I am doing"
My Blog
Suanhacky Lodge #49
Rebel Squadrons

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > mysql_num_rows(...) problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway