This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[SOLVED] count url

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

[SOLVED] count url

Post by Fire-Fox »

what is wrong here :

Code: Select all

	#Url
	set sqlsiteurl "SELECT COUNT(DISTINCT(siteurl)) FROM home WHERE siteurl='siteurl'"
	set siteurl [mysqlsel $mysql_(handle) $sqlsiteurl -flatlist]
Last edited by Fire-Fox on Sat Mar 03, 2012 7:28 pm, edited 1 time in total.
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Well, that'd depend on the database structure and contents, as well as the expected results...
Anyhow...

Code: Select all

SELECT COUNT(DISTINCT(siteurl))
Return the number of unique siteurl's from the filtered set.

Code: Select all

WHERE siteurl='siteurl'
Filter the results to only return rows where the field siteurl is equal to the string "siteurl".

If you expect this to return anything other than 0 or 1, then you need to rethink your query.
NML_375
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

sql injection ftw. Make sure you escape the user given variables
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Johannes13, since there are no variable substitutions within the query of the posted code, I don't see the relevance of sql injections.
NML_375
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

Thanks nml375 :)
Did it like this :

Code: Select all

#Url
set sqlsiteurl "SELECT COUNT(DISTINCT(siteurl)) FROM pred"
set siteurl [mysqlsel $mysql_(handle) $sqlsiteurl -flatlist]
and returned 715 urls :)
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
Post Reply