Jump to content

[SOLVED] variables not being added to database


Jnerocorp

Recommended Posts

hello,

 

I have this code:

 

<?php

if(isset($_GET['q'])) {

$tag=$_GET['q'];

echo "$tag";

$query="SELECT * FROM tags WHERE tag='$tag'";
$result = mysql_query($query);
if($row=mysql_fetch_assoc($result))
{
//UPDATE 
$increment = $row['views']+1;
$tags = $row['tag'];
$query1 = "UPDATE tags SET views='$increment' WHERE tag='$tags'";
mysql_query($query1);
}
else
{
//INSERT 
$implicit=1;
$query2 = "INSERT INTO tatgs (tag, views) VALUES ('$tag', '$implicit')";
mysql_query($query2);
}
}
    ?>

 

the echo "$tag"; was just so i could make sure that it was getting the variable and it was.

 

but this code is not working its suppposed to check if that tag already exists if it does update  it by 1 view if not add it to the database with 1 view

 

but it does nothing

 

-John

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.