Old 15-10-2006, 19:45   #1 (permalink)
raptrex
Registered User
 
Join Date: Oct 2006
Posts: 13
php mysql help

ok my link is suppose to look like this: index.php?foo=1
so it grabs the data from the table with 1
and votes is a number like 2
this works
but when trying to insert the new data back into the database, it doesnt work
plz check my code

PHP Code:
<?php 
$foo
=$_GET[foo];
include(
"config.php");
$query="SELECT * FROM links WHERE id=$foo";
$result=mysql_query($query);

$num=mysql_numrows($result);


$theid=mysql_result($result,$id,"id");
$title=mysql_result($result,$id,"title");
$post=mysql_result($result,$id,"post");
$date=mysql_result($result,$id,"date");
$votes=mysql_result($result,$id,"votes");
$url=mysql_result($result,$id,"url");

$add $votes+1;
echo 
"$votes";

mysql_query("INSERT INTO links(votes) WHERE id=$foo VALUES('$add')");
mysql_close();

echo 
"$title now has $add votes";
?>
  Reply With Quote
Old 15-10-2006, 19:57   #2 (permalink)
freelancr
Senior Member
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,178
mysql_query("INSERT INTO links(votes) WHERE id=$foo VALUES('$add')");

change to:
mysql_query("UPDATE links SET votes = $add WHERE id = $foo");

Last edited by freelancr : 15-10-2006 at 20:23.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8