Jump to content

[SOLVED] mysql site counter


ohdang888

Recommended Posts

hey.

i want to create a counter for a page using mysql.

 

does mysql let you use php to perform functions on the information retrieved?

 

and if so, it would the outline be...

 

-connect

-get old counter value

-add 1(using php)

-save new value

-display new value-

 

????????????????

Link to comment
https://forums.phpfreaks.com/topic/83853-solved-mysql-site-counter/
Share on other sites

well i tried to do this:

 

for example... it would be in game.php?title=2deep

and would grab all the info from the row of 2deep, including the counter

<?php
function sql_quote($data) {
  if (get_magic_quotes_gpc()) {
  $data = stripslashes($data);
  }

return addslashes($data);
}

$game = sql_quote($_GET['title']);

mysql_connect("localhost", "-----", "-----") or die(mysql_error());
mysql_select_db("games") or die(mysql_error());

$result = mysql_query("SELECT `author`,`title`,`author_url`,`type`,`flash`,`game_picture_url`,`game_file_name`,`instructions`,`counter` FROM `game` WHERE `title`='{$game}'") or die(mysql_error()); 

$row = mysql_fetch_array($result);

$oldcounter = stripslashes($row['counter']); 
$oldcounter++ = $newcounter
?>

buts its saying the stuff below the array is not valid.

 

Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\counter.php on line 21

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.