Jump to content

PHP Code Help Needed


dual_alliance

Recommended Posts

Hello,

l attempted to make a code which would run via CRON once a day that made it so it -1 from anyone who has been banned.  However after trying it didn't work... and l deleted the code by mistake.  But could someone please show me how to make the code that will update the banned days column and subtract 1 from any user that is their?

Thankyou,

dual_alliance

[b]Edit: [/b] Found the code of my hd, see bottom of page for it except it doesnt work.
Link to comment
Share on other sites

okay if you already know your query string then just do a simple connection and query script:

[code]
<?php
  $conn = mysql_connect('localhost','username','password');
  $db = mysql_select_db('dbname',$conn);
  $sql = "query string here";
  $result = mysql_query($sql, $conn);
?>
[/code]

that's a barebones version.  dunno if you wanna throw in some error trapping/logging or whatever. Anyways. just make a file called blah.php or whatever and point your cron job to it.

edit: p.s.- I guess this belongs in the php forums after all ;D
Link to comment
Share on other sites

Hey l found backup of the code after searching my hole hd ;D, well heres what l had...

[code=php:0]<?php
require_once('settings.php');
// Connect to the database
@mysql_connect("$dbhost", "$dbusername", "$dbpassword") or die ('Cannot connect to MySQL database');
@mysql_select_db("$dbname") or die ('Cannot select database');

$i = 1;
$sql = "SELECT `ban.days` FROM `banned` WHERE `ban.days` >= '$i' ";
$result = mysql_query($sql) or die("Problem with the query: $sql <br>" . mysql_error());
$row = mysql_fetch_assoc($result);
$i2 = $row['ban.days'];
$ri = $i2 - $i;
$sql1 = "UPDATE `banned` SET `ban.days` = '$i2 - 1'  WHERE `ban.days`= '$i2' ";
$result1 = mysql_query($sql1) or die(mysql_error());
?>[/code]

Maybe this gives you more of an idea of what l am trying to do.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.