Jump to content

big problam with updating


redarrow

Recommended Posts

advance thank you.

big problam today with my stats updating for my members what happens a user go to see anothe users profile and the stats colum should update via the date and the users id.

now all this was working the first entry get put in the database correctly but if you goto the same profile agin the database does not update the next entry i have echoed querys are all correct any idear cheers.

here the update query echoed out
[code]

update hits set Dec=Dec+1 where id='65535'

update problam
[/code]
[code]
<?php session_start();

$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("xxxx",$db);

$name=$_GET['name'];

$query="select * from members where name='$name'";
$result=mysql_query($query);

while($record=mysql_fetch_assoc($result)){

if($_GET['cmd']=="hit"){

$colname=($_POST['colname']);

$colname=date('M');

$query1="select * from hits where id='".$record['id']."'";
$result1=mysql_query($query1)or die("query problam");

if(!mysql_num_rows($result1)){

$id=$record['id'];
$jan="1";
$feb="1";
$mar="1";
$apr="1";
$may="1";
$jun="1";
$jul="1";
$aug="1";
$sep="1";
$oct="1";
$nov="1";
$dec="1";

$insert="insert into hits (`id`, `jan`, `feb`, `mar`, `apr`, `may`, `jun`, `jul`, `aug`, `sep`, `oct`, `nov`, `dec`)values('$id','$jan','$feb','$mar','$apr','$may','$jun','$jul','$aug','$sep','$oct','$nov','$dec')";
$in=mysql_query($insert)or die("insert problam");

}elseif(mysql_num_rows($result1)>0){

$update="update hits set $colname=$colname+1 where id='".$record['id']."'";
$resultu=mysql_query($update)or die("update problam");
}
}
[/code]
Link to comment
Share on other sites

database info
[code]
Field Type Attributes Null Default Extra Action
  id smallint(5)  UNSIGNED ZEROFILL Yes NULL               
  jan varchar(100)  No                 
  feb varchar(100)  No                 
  mar varchar(100)  No                 
  apr varchar(100)  No                 
  may varchar(100)  No                 
  jun varchar(100)  No                 
  jul varchar(100)  No                 
  aug varchar(100)  No                 
  sep varchar(100)  No                 
  oct varchar(100)  No                 
  nov varchar(100)  No                 
  dec varchar(100)  No
[/code]
Link to comment
Share on other sites

update hits set Dec=Dec+1 where id='00000'You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Dec=Dec+1 where id='00000'' at line 1

from this

$update="update hits set $colname=$colname+1 where id='".$record['id']."'";
echo $update;
$resultu=mysql_query($update)or die(mysql_error());

Link to comment
Share on other sites

craygo the colname is working correctly the way i had it i tried your method but no joy, what colname is doing is getting the month name and then updating the database set on that month name so that correct as what i can see the id has got a double quote and the start of the stats got a single qoute for a strange reason.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.