Jnerocorp Posted November 4, 2009 Share Posted November 4, 2009 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 Link to comment https://forums.phpfreaks.com/topic/180235-solved-variables-not-being-added-to-database/ Share on other sites More sharing options...
Jnerocorp Posted November 4, 2009 Author Share Posted November 4, 2009 nevermind lol it was just a little typo in table name -John Link to comment https://forums.phpfreaks.com/topic/180235-solved-variables-not-being-added-to-database/#findComment-950794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.