Hey y'all


This is my first time that i try something with mysql and/or db's btw.


I created a table called images with only 3 colums named "pid", "filename" and "views" with this:

PHP Code:
<?php 
    $connection 
mysql_connect("host.name"
        
"dbuser"
        
"dbpass"); 

    
mysql_select_db("dbname"$connection); 

echo 
"Connected to MySQL<br />";
mysql_select_db("dbname") or die(mysql_error());
echo 
"Connected to Database<br />";


// Create a MySQL table in the selected database

mysql_query("CREATE TABLE tablename(
pid INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(pid), filename VARCHAR(30), views VARCHAR(7)"
)
 or die(
mysql_error());  

echo 
"Table tablename Created!";

?>

but i think the problem is on this code. The "views" value on the specified row by the pid, is not incremented.

the image(s) here are called like:

somesite.com/page.php?imid=X
(where X is some number)


PHP Code:
<html>
<head>
<title>some title</title>
</head>
<BODY>

<?php 



<?php 

$connection 
mysql_connect("host.name"
        
"dbname"
        
"dbpass"); 

    
mysql_select_db("dbname"$connection); 





$pid $_GET['imid'];




// This is the part that Increments count of views, but is not working. 

function increment($pid)
{
   
// Get data for page title
   
$increment_query 'SELECT *
                                 FROM pics
                                 WHERE pid = '
.$pid.'';
   
$increment_result mysql_query($increment_query); 

   
$increment_row mysql_fetch_array($increment_result);   

   
// Get count data
   
$views $increment_row['views']; 

   
// Increment $count
   
$views++;
 
   
// Put new value into database
   
$increment_query 'UPDATE tablename 
                                  SET views = '
.$views.
                                  WHERE pid = '
.$pid.'';
   
$increment_result mysql_query($increment_query);






// Get a specific result from the table 
$result mysql_query("SELECT * FROM pics
 WHERE pid='
$pid'") or die(mysql_error());  
$row mysql_fetch_array$result );





$openpic $row['filename'];

echo 
"<img src='$openpic' alt=''";
echo 
"<br><br>";

?> 

</body>
</html>

i googled about it and also found

PHP Code:
UPDATE MyTable SET MyColumn=MyColumn+1 Where MyID=123 

and tried this other code for my function increment($pid)


PHP Code:
function increment($pid)
{
   
// Get data for page title
$increment_query 'UPDATE tablename SET views = views+1  WHERE pid= '.$pid.'';

but nothing works. the problem must be easy to correct, but i know very little about this. remember... my 1st time "mysqling"!

thanks in advance...