Dan13071992
11-26-2011, 12:27 AM
I would like to implement this code below:
if (strip_tags($_POST['production']) == "Yes"){
$production=$_POST['production'];
mysql_query("UPDATE bf SET stock=stock+0 WHERE producing='$production'");
mysql_query("UPDATE bf SET stock=stock+1000 WHERE _countryid='$fetch->_countryid'");
mysql_query("UPDATE users SET money=money-1000 WHERE username='$fetch->username'");
into my inc-functions.php file:
<?php
function optCountries($sel) {
$result='';
$query=mysql_query("SELECT * FROM countries ORDER BY country ASC");
while ($row=mysql_fetch_assoc($query)) {
$result.='<option value="'.$row['id'].'"'.($sel==$row['id'] ? ' selected' : '').'>'.$row['country'].'</option>';
}
return $result;
}
function makePassword($len) {
$pass='';
$allowed='Taken Out For Security';
for ($i=1;$i<=$len;++$i) {
$pass.=$allowed[mt_rand(0,strlen($allowed))];
}
return $pass;
}
function generateCode() {
$valid='Taken Out For Security';
$strCode='';
for ($i=0;$i<10;++$i) {
$strCode.=$valid[mt_rand(0,strlen($valid))];
}
return $strCode;
}
function dbSafe($txt) {
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {$txt=stripslashes($txt);}
return mysql_real_escape_string($txt);
}
function makecomma($input)
{
if(strlen($input)<=3)
{ return $input; }
$length=substr($input,0,strlen($input)-3);
$formatted_input = makecomma($length).",".substr($input,-3);
return $formatted_input;
}
?>
The idea is so that if in the bf the status is set to 'producting=yes' then every hour on the hour it adds 1000 to the stock in each bf, however I am wondering if this is possible to do without anyone logged into the site, as inc-functions is the sites functions as you can see, i also have inc-userfunctions.php which is to update users online sessions ect.
Is this possible to do, if so how?
Thanks.
Dan
if (strip_tags($_POST['production']) == "Yes"){
$production=$_POST['production'];
mysql_query("UPDATE bf SET stock=stock+0 WHERE producing='$production'");
mysql_query("UPDATE bf SET stock=stock+1000 WHERE _countryid='$fetch->_countryid'");
mysql_query("UPDATE users SET money=money-1000 WHERE username='$fetch->username'");
into my inc-functions.php file:
<?php
function optCountries($sel) {
$result='';
$query=mysql_query("SELECT * FROM countries ORDER BY country ASC");
while ($row=mysql_fetch_assoc($query)) {
$result.='<option value="'.$row['id'].'"'.($sel==$row['id'] ? ' selected' : '').'>'.$row['country'].'</option>';
}
return $result;
}
function makePassword($len) {
$pass='';
$allowed='Taken Out For Security';
for ($i=1;$i<=$len;++$i) {
$pass.=$allowed[mt_rand(0,strlen($allowed))];
}
return $pass;
}
function generateCode() {
$valid='Taken Out For Security';
$strCode='';
for ($i=0;$i<10;++$i) {
$strCode.=$valid[mt_rand(0,strlen($valid))];
}
return $strCode;
}
function dbSafe($txt) {
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {$txt=stripslashes($txt);}
return mysql_real_escape_string($txt);
}
function makecomma($input)
{
if(strlen($input)<=3)
{ return $input; }
$length=substr($input,0,strlen($input)-3);
$formatted_input = makecomma($length).",".substr($input,-3);
return $formatted_input;
}
?>
The idea is so that if in the bf the status is set to 'producting=yes' then every hour on the hour it adds 1000 to the stock in each bf, however I am wondering if this is possible to do without anyone logged into the site, as inc-functions is the sites functions as you can see, i also have inc-userfunctions.php which is to update users online sessions ect.
Is this possible to do, if so how?
Thanks.
Dan