|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Quote:
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 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. |
|
#3
|
|||
|
|||
|
when you execute
$check = mysql_query(...); call echo mysql_error(); directly underneath it, to echo out the error |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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"; } |
|
#6
|
|||
|
|||
|
the database table is called information and whatever you call the suttf inside it, one of them is called username
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
|||
|
|||
|
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)
|
|
#10
|
|||
|
|||
|
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?
|
|
#11
|
|||
|
|||
|
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.
|
|
#12
|
||||
|
||||
|
PHP Code:
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > mysql_num_rows(...) problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|