count for PHP 5.3.6

Started on the old forum in July 2011 · view the original in the archive · old links redirect here

4 replies · 354 views · started 15 years ago · 1 min read

4 participants
crazybrumi Super moderator Principal · 1,064 posts #1

has something changed for this as im just coding a new site and im tryning to use the count to count rows to see if a user exist. but it keeps giving me an error, its like i put it back to front.

if i put test as a username in the login box this is the error i get Unknown column 'test' in 'where clause'

this is the code iv tried

$count_users=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM members WHERE username=".$userid."")) or die(mysql_error());

$check_pass=mysql_num_rows(mysql_query("SELECT username,password,COUNT(*) FROM members WHERE username=".$userid." AND password=".$protect."")) or die(mysql_error());

any help as usual always appreciated, if you got any material on this would be even better.

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

morse Senior · 364 posts #2
[COLOR=#000000][COLOR=#0000BB]$count_users[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]mysql_fetch_array[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"SELECT COUNT(*) FROM members WHERE username='"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$userid[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]"'"[/COLOR][COLOR=#007700])) or die([/COLOR][COLOR=#0000BB]mysql_error[/COLOR][COLOR=#007700]());

[/COLOR][COLOR=#0000BB]$check_pass[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]mysql_num_rows[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]mysql_query[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"SELECT username,password,COUNT(*) FROM members WHERE username='"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$userid[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]"' AND password='"[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]$protect[/COLOR][COLOR=#007700].[/COLOR][COLOR=#DD0000]"'"[/COLOR][COLOR=#007700])) or die([/COLOR][COLOR=#0000BB]mysql_error[/COLOR][COLOR=#007700]());  [/COLOR][/COLOR]

ignore the upper code box, something is breaking my post everytime 🙁 Corrected 🙂 its just '' missing in the statements

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

subzero Super moderator Fellow · 3,954 posts #4

i was going to say something but nah lmao

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

something else Fellow · 2,296 posts #5

ummmmm why you selecting field names from: $check_pass=mysql_num_rows(mysql_query("SELECT username,password,COUNT(*) FROM members WHERE username='".$userid."' AND password='".$protect."'")) or die(mysql_error());

when using mysql_num_rows ?

it should return a number making the field names pointless

$check_pass=mysql_num_rows(mysql_query("SELECT * FROM members WHERE username='".$userid."' AND password='".$protect."'")); //also dont mysql_error your giving away valuable data if you do so

Added after 8 minutes:

if you need to use mysql_error you can use it like this:

$debug = " or die(mysql_error())";

$check_pass=mysql_num_rows(mysql_query("SELECT * FROM members WHERE username='".$userid."' AND password='".$protect."'")$debug);

then just comment out the debug line when you make the script active will stop hackers getting hold of database names and fields

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close