spfoonnewb Posted January 14, 2007 Share Posted January 14, 2007 So I made this script, it checks for the name and id include.. and only runs if its set. When I do set it, such as ?id=1&name=test, it says there is an error. If I take (, name='$name") out, it has no error. But does not update the variable.[code]<?phpif (!empty($_GET["name"]) && $_GET["id"]) {$link = mysql_connect("localhost", "username", "password") or die(mysql_error());mysql_select_db("database") or die(mysql_error());$name = $_GET["name"];$id = $_GET["id"];mysql_query ("UPDATE cat SET count=count+1 WHERE id='$id', name='$name") or die(mysql_error());mysql_close ($link);}else {//Do Nothing}?>[/code] Link to comment https://forums.phpfreaks.com/topic/34166-msql-counter-help/ Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Share Posted January 14, 2007 UPDATE cat SET count=count+1 WHERE id='$id' AND name='$name' Link to comment https://forums.phpfreaks.com/topic/34166-msql-counter-help/#findComment-160701 Share on other sites More sharing options...
spfoonnewb Posted January 14, 2007 Author Share Posted January 14, 2007 Thx.. that worked. Although it doesn't explain why it doesn't work with just one :) Link to comment https://forums.phpfreaks.com/topic/34166-msql-counter-help/#findComment-160703 Share on other sites More sharing options...
corillo181 Posted January 14, 2007 Share Posted January 14, 2007 2 reason that ',' out of no where might mess up the code and the $name only had one ' on the left side not the closing one.edit..plus the and just search for fields that matches the counter is like reading it.. set counter plus one where id is 1 and the name is 2. Link to comment https://forums.phpfreaks.com/topic/34166-msql-counter-help/#findComment-160704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.