Re: adding an incremented count from page hits
On Wednesday 23 March 2005 20:00, Chip Wiegand wrote: count=count+1; --- This is the added bit --- ? --- The count doesn't increment in the database. The table has a column called 'count'. Two things: variables start with a $ and the variable count in your example does not... this means error!, change the count to $count 2nd, You should update your table like this: mysql_query(UPDATE `manuals_list` SET `count`='$count' WHERE ...selection here... LIMIT 1;); Also, I see that you are ignoring mysql security! Please think about sql injection attacks. You should use the mysql_escape_string function on any and all user inputed values, use backticks to delimit database/table/field names, and quotes to delimit values. Can someone please please point me in the right direction? Thanks, http://dev.mysql.com/doc/mysql/ Andy -- Registered Linux User Number 379093 -- Feel free to check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- pgpVeoCP0qrd6.pgp Description: PGP signature
adding an incremented count from page hits
I have an existing database/tables and would like to add a counter to a table that would increment when a document is downloaded from the database. I am sure it is an easy addition to the php page but struck-out looking for info not related to auto-increment in the mysql manual. I tried adding this to the php page: (more else statements up here) elseif ($orderby == 'bg'): $sql = select * from manuals_list where cat like 'bg' order by 'file_name'; else: $sql = select * from manuals_list where cat like 'ap' order by 'file_name'; endif; $result = mysql_query($sql); while ( $row = mysql_fetch_array($result)) { printf(tr\ntd class=\link\\n a href='../docs/$row[url]'%s/a\n/td\ntd%sKB/td\ntd%s/td\n/tr\n, $row[file_name], $row[size], $row[rev]); } count=count+1; --- This is the added bit --- ? --- The count doesn't increment in the database. The table has a column called 'count'. Can someone please please point me in the right direction? Thanks, Chip -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]