Jump to content

Problem with mysql php stuff


Ristiisa

Recommended Posts

Hello,im beginner with php and mysql,and i have an game,im learning on it etc,but i have problem,i want to make an energy,that it will update the energy with 5 on every 15 mins(for that im using cron jobs,i know how to use them),but i dont know how to make it

 

i want to make it like

it will add 5 energy into the energy column or smth,and the old one stays,so if it was 10,it will be 15.

and if its more then 100,it will put it to 100.

 

thanks,my english is kinda bad so yeah,i really would be happy if someone could help me and teach me it.

Link to comment
Share on other sites

Are you asking about MySQL or CRON? Which part are you having issues with? Writing the SQL? Creating the CRON job?

with MySQL,i know how to set up cron jobs,but problem is with the mysql thingy

 

 

i tried

("UPDATE users SET energy=energy+5 WHERE energy < 95");

but it wont work,oh and it should add energy to every playes who is in users table

Link to comment
Share on other sites

idk why i cant edit the text in this forums anymore,wanted to write that full scripts is

 

<?php
$username = "gsagsa";
$password = "gsagas";
$hostname = "localhost"; 


$dbhandle = mysql_connect($hostname, $username, $password);
$selected = mysql_select_db("plapla",$dbhandle);

$set=array();

("UPDATE users SET energy=energy+5 WHERE energy < 95");
?>

Link to comment
Share on other sites

take a look at http://php.net/manual/en/function.mysql-query.php

 

You have to execute the query,

 

mysql_query("UPDATE users SET energy=energy+5 WHERE energy < 95");
echo mysql_error();

 

The last line should tell you if something went wrong.  This isn't the cron job, but should move you the right direction.  It is likely though that there is something missing from this conversation though....

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.