Jump to content

Please Help Me


skwap

Recommended Posts

Friends,

 

iam developing a small website & i used php & mysql.

 

i have a problem small problem with sql update statement.....

 

HERE IS MY DATA BASE TABLE

 

id    pubtoday    pubtotal    todayclicks    totalclicks    today_is

1      2.00              5.00          200                5000          29/2011/07

 

 

 

I want to update all user's pubtoday & todayclicks fields as 0 if the today_is date is not match with today date & also update new date.

Consider Above Code (I Used)

 

$today = date("d/Y/m");

$update = mysql_query("UPDATE `statistics` SET `pubtoday` = '0.00' , `todayclicks` = '0' WHERE `today_is`!=$today");

if($update) {

$update1 = mysql_query("UPDATE `statistics` SET `today_is` = '$today' WHERE `today_is`<>$today");

}

 

but here iam facing a problem that is pubtoday & todayclicks is setting as 0 if the date match. I need only update if the $today date is not match with db stored date.

 

 

Please help me... & what is the error ??

 

 

 

 

Link to comment
Share on other sites

i changed the today_is data type to date & also made a small changes in the code (added quotes surrounded by $today)...

 

Ya Its Got Worked !

 

Thank You...........................

 

Could you please explain what may be the error occurred their ??

is it the problem of data type / in coding ?

Link to comment
Share on other sites

Stings need to be surrounded by quotes. So do dates actually. But yeah,, you should always use a date type when dealing with dates, this way if you ever need to sort by date or do any other queries based on dates you can use the date functions.

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.