PHP - Moved: Transfering Cron Jobs (server)
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=333230.0 Similar TutorialsThis topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=306518.0 hello im having trouble with this code im not sure if you can help me but ima paste the code here and i will see what people say, the problem is this: PHP Fatal error: require(): Failed opening required '../class/class_db_mysql.php' (include_path='.:') in /var/www/vhosts/dclxvi.co.uk/httpdocs/crons/cron_day.php on line 6 my code is this: <?php include_once ('../Global/config.php'); global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "../class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $db->query("UPDATE fedjail set fed_days=fed_days-1"); $q=$db->query("SELECT * FROM fedjail WHERE fed_days=0"); $ids=array(); while($r=$db->fetch_row($q)) { $ids[]=$r['fed_userid']; } if(count($ids) > 0) { $db->query("UPDATE users SET fedjail=0 WHERE userid IN(".implode(",", $ids).")"); } $db->query("DELETE FROM fedjail WHERE fed_days=0"); $db->query("UPDATE users SET daysingang=daysingang+1 WHERE gang > 0"); $db->query("UPDATE users SET daysold=daysold+1, boxes_opened=0"); $db->query("UPDATE users SET mailban=mailban-1 WHERE mailban > 0"); $db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0"); $db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0"); $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0"); $db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>0"); $q=$db->query("SELECT * FROM users WHERE cdays=0 AND course > 0"); while($r=$db->fetch_row($q)) { $cd=$db->query("SELECT * FROM courses WHERE crID={$r['course']}"); $coud=$db->fetch_row($cd); $userid=$r['userid']; $db->query("INSERT INTO coursesdone VALUES({$r['userid']},{$r['course']})"); $upd=""; $ev=""; if($coud['crSTR'] > 0) { $upd.=",us.strength=us.strength+{$coud['crSTR']}"; $ev.=", {$coud['crSTR']} strength"; } if($coud['crGUARD'] > 0) { $upd.=",us.guard=us.guard+{$coud['crGUARD']}"; $ev.=", {$coud['crGUARD']} guard"; } if($coud['crLABOUR'] > 0) { $upd.=",us.labour=us.labour+{$coud['crLABOUR']}"; $ev.=", {$coud['crLABOUR']} labour"; } if($coud['crAGIL'] > 0) { $upd.=",us.agility=us.agility+{$coud['crAGIL']}"; $ev.=", {$coud['crAGIL']} agility"; } if($coud['crIQ'] > 0) { $upd.=",us.IQ=us.IQ+{$coud['crIQ']}"; $ev.=", {$coud['crIQ']} IQ"; } $ev=substr($ev,1); if ($upd) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET us.userid=us.userid $upd WHERE u.userid=$userid"); } $db->query("INSERT INTO events VALUES('',$userid,unix_timestamp(),0,'Congratulations, you completed the {$coud['crNAME']} and gained $ev!')"); } $db->query("UPDATE users SET course=0 WHERE cdays=0"); $db->query("TRUNCATE TABLE `votes`"); ?> PHP + MySQL This has been doing my head in, it has to be possible how I think it is. The thing I am trying to achieve here is let's say a list of users logged in. Now if every one would click logout and use the system correctly the world would be a better place, but they wont, we all know this. So I was thinking how to counter this and I came up with an idea, lets say in our users table we have an "ACTION" field as a timestamp (or datestamp??). So everytime the user does anything on my site, edit there profile, browse something etc etc, it updates the "ACTION" field to the current time. I was thinking in the background I could have a cron job run every.. 5 minutes? Is it possible to have it check EVERY users ACTION field and if there ACTION field is less than the current time - 5 minutes, it updates there LOGGED_IN field to like 0, which would mean they're actually not logged in anymore and would not appear in the logged in list. Someone tell me yes or no! (The main problem being having to constantly update that ACTION field) Hello there.. my webhost doesn't have Cron Jobs feature.. is there any alternative php script in able to run my php script every minute ?? i have a website containing mafia game.. it's coded in php.. i tried to use Code: [Select] <META HTTP-EQUIV="Refresh" CONTENT="60; URL=http://test.com/run_minute.php">but this will work only if the user is in the existing page where this code placed.. i want it something like, the http://test.com/run_minute.php will refresh every minute.. even thou the user is not on the page.. Thank you. More power.. Basically I am setting up my own cricket management game, but there are 3 areas that I am slightly stuck on and would appreciate help: 1) When a use registers, I need to create 11 players for their team. For this, I am going to have one text files with first names and one text file with surnames. How can I open each file and select a name and then match them together? 2) I need to create the list of games to be executed at particular times through a cron job. How can I go through all the teams in a table and match them together in games, ensuring everyone plays everyone? If a new player registers, he will be put into a random league and so the games for that league will have to be redone 3) How can I set up a cron job to execute the above games? Each team should play once a day and so if there are 24 teams in a table, there will be 12 games that occur through this cron job. I assume cron jobs are the best thing for this. Any help would be appreciated. Thanks. Always humbling to be knocked on your arse by what you think would be so easy... How can I run a std mysql_query command like this from cron? $query_insert_new = mysql_query("INSERT INTO members (ID, name, date)VALUES (NULL,'$new_name',CURDATE())"); It is a long time since I firstt learnt how to access mysql from the command line via pUTTY or cmd... However I never learnt how to write a php script in the same fashion... I have configured cron to run correctly and the script runs. After testing however I was wondering how my database was not getting updated... then i realised I must have to enter the commands as if command line... I tried but don't know where to start. Do I have to connect to the database in the same fashion you do in cli: mysql -u username -p password ? This is my script. The idea is to cycle every 7 days and write over old files. It is very simple, but all i need. The table has 3 fields, ID name date. <?php $db_username = "username"; $db_password = "password"; $db_hostname = 'localhost'; $db_database = 'databasename'; //first log into the database $db_server = mysql_connect($db_hostname, $db_username, $db_password); //selecting databse mysql_select_db($db_database, $db_server); //now get the latest entry in the table 'database_backup_info' $query_latest_entry = mysql_query("SELECT name FROM database_backup_info ORDER BY ID DESC LIMIT 1 "); //if there are results in the table if(mysql_num_rows($query_latest_entry)>0) { //retrieving the info $query_latest_entry_row = mysql_fetch_assoc($query_latest_entry); //now determine the new file number based on the last entry if($query_latest_entry_row['name'] + 1 > 7) { $new_name = $query_latest_entry_row['name'] + 1; } else { $new_name = 1; } //insert the entry into the db $query_insert_new = mysql_query("INSERT INTO members (ID, name, date) VALUES (NULL,'$new_name',CURDATE())"); } //if no results then this will be the first entry else{ $new_name = 1; //insert the entry into the db $query_insert_new = mysql_query("INSERT INTO members (ID, name, date) VALUES (NULL,'$new_name',CURDATE())"); } //creating the file path and name $db_backupFile= dirname(__FILE__).'/sql_files/'.$new_name.'.sql'; //the mysql dump command $command = "mysqldump -u$db_username -p$db_password -h$db_hostname $db_database > $db_backupFile"; //running the mysql_dump command system($command, $result); ?> This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347320.0 This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=334310.0 This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=317079.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=346879.0 if i got some homepage named index.php and got a $_GET function which calls index.php?strana=2, how do i define so my index.php or just www.example.com/folder/ is same like index.php?strana. Cuz Ive got 2 forms on my website and when i put index.php?strana - i get the first one, when i put index.php?strana=2 - i get the second one but when i put index.php only or blank as i said above im still getting second form Hello everybody!
I'm here today with a mystery i can't solve...
The problem i'm having is that i need to be able to transfer mysql data from one server to another one.
Retrieving data from the one database is easy, but making it transfer to another server is not that easy for me.
I have it printing out the data ATM
This is how i retrieve data from one server:
<?php $dbhost = ""; $dbname = "eg_xenforo"; $dbuser = ""; $dbpass = ""; $conn = mysqli_connect("$dbhost","$dbuser","$dbpass","$dbname") or die("Error " . mysqli_error($conn)); $sql= "SELECT username FROM xf_user WHERE FIND_IN_SET('9',secondary_group_ids) UNION SELECT username FROM xf_user WHERE FIND_IN_SET('10',secondary_group_ids) UNION SELECT username FROM xf_user WHERE FIND_IN_SET('12',secondary_group_ids)"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { $name = $row['username']; echo "$name <br>"; } } else { echo "0 results"; } ?>This is what i get as result: CosmonautBob ooglebrain JamieKG Quinnter16 Jordan Zoehamp skynet1123 misscupcake1306 Sir CrimsonThese are usernames that should be added onto another server in a database table. Any suggestions? Thanks in advance! I have been looking around and have not been able to find any useful information on this. I am trying to transfer files from a folder in the directory to a table in a database. Eventually they will be images but for right now I am just trying to get text files to transfer. Any help/code/ideas would be a lot of help. This is going to be triggered a button on a page by the way. From the beginning, the user accesses my website and uploads an image. Currently I'm using SimpleImage.php available at http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php to resize uploaded pictures. I create two copies, a regular size and a thumbnail size. Then I transfer the converted files through FTP to my storage server. The regular size works great, but the thumbnail transfers as a blank file. I don't want to save the files on the non-storage server at all, so I'm trying to work with temporary files. include('./SimpleImage.php'); // A few variables $file_name = basename($_FILES['photo1']['name']); $random_digit=mt_rand(111111111,2147483647); // New file name $new_file_name = $userInfo['id'].'_'.$random_digit.$random_digit.'_'.substr($file_name, -5); // Paths to temporary files $target_path = $_FILES['photo1']['tmp_name']; $thumb_path = tmpfile(); // Start SimpleImage and load temp file $simImage = new SimpleImage(); $simImage->load($target_path); // Get the temp image dimensions list($width, $height) = getimagesize($target_path); // Resize the file if it's too tall if ($height > $var['maxPhotoHeight']) { $simImage->resizeToHeight($var['maxPhotoHeight']); $simImage->save($target_path); } // Get the newly resized image dimensions list($width, $height) = getimagesize($target_path); // Resize the image if it's too wide if ($width > $var['maxPhotoWidth']) { $simImage->resizeToWidth($var['maxPhotoWidth']); $simImage->save($target_path); } // Resize for thumbnail width $simImage->resizeToWidth($var['thumbWidth']); $simImage->save($thumb_path); // Get thumbnail dimensions list($width, $height) = getimagesize($thumb_path); // Resize the thumbnail if it's too tall if ($height > $var['thumbHeight']) { $simImage->resizeToHeight($var['thumbHeight']); $simImage->save($thumb_path); } // Was told this was important, but I've tried with and without it and got the same result fseek($thumb_path,0); // Perform File Transfer ftpTransfer($target_path, "$new_file_name"); ftpTransfer($thumb_path, "thumbs/$new_file_name"); // My Simple FTP Transfer Function: function ftpTransfer($source, $name) { global $ftp; $ftpMeta = "ftp://" . $ftp['user_name'] . ":" . $ftp['user_pass'] . "@" . $ftp['server'] . $ftp['dir'] . $name; $ftpData = file_get_contents($source); file_put_contents($ftpMeta, $ftpData); } Like I said, the regular sized image works great!! the thumbnail file is only created on the storage server but it has a 0kb file size. I'm sure it has to do with me working with a temporary file. tmpfile() claims to remove the file after it's closed, so maybe by using the Save feature in SimpleImage, it's closing the file and then the server automatically removes the temporary file? SimpleImage has a feature where I can write the image output [possibly to a file] using $simImage->output() for the data. If that helps with a solution? I don't know. I know it might be complicated, but any help is appreciated! Hey..
So lately I've been hooking up large requests to resque jobs in my application, for the purpose of not keeping the user(s) waiting for a longer period of time before they can continue using the application. At the same time, I have a frontend library & eventlistener alerting the users when any specific job was actually completed by the workers. I have realized however that in some cases, this doesn't pan out.
I love the idea of resque jobs, but my gut feeling is that I somehow lose control of the request I'm processing. The reason I'm posting this is because there's one part of my application that processes an insane amount of data, in a loop(!). Obviously this can take a long time, and that's to be expected. But when an error occurs along the way, I have no good way of logging it nor alerting the user about it.
Picture a scenario where a Worker is doing a Job that would take 2 minutes, and is 80% done, at which point it fails for whatever reason. How would you recommend something like this to be handled?
Obviously I get internal logs from the jobs the workers perform, but more specifically how would you catch the errors right from the script? Currently this is my setup...
try { ...//code that takes > 1min } catch(AppException $error) { ...//Internal code error, catch } catch(SeqDbException $dbError) { ..//DbError or Query } catch(SystemException $exception) { ..//More severe exceptions }Either I'm missing a catch, or I'm missing something else. The errors rarely occur as well, so it's not easy for me to debug it or re-create them. It's very dependent on the data that is being processed. Hi guys, I am trying to get data from the table "jobs" and insert its id and name into table "bookings" I can get the job "name" from "jobs", which is fine, using the following: <select class="form-control" id="tour_name" name="tour_name"> <option value="Select">== Select Tour or Charter ==</option> <?php $sql = "SELECT name FROM jobs"; $result = $con->query($sql); while(list($name) = mysqli_fetch_row($result)){ ?> <option value="<?php echo $name ?>"><?php echo $name;?></option> <?php } ?> </select> However, when I click submit to insert into "bookings" everything goes in except "booking_id" which is "id" in "jobs". Hope this makes sense. I am using the following to insert: if(isset($_POST['new']) && $_POST['new']==1){ $sql = "SELECT id FROM jobs"; $result = $con->query($sql); while(list($id) = mysqli_fetch_row($result)){ } $tour_id = isset($_GET['id']) ? $_GET['id'] : ''; $tour_name = mysqli_real_escape_string($con, $_POST['tour_name']); $customer_name = mysqli_real_escape_string($con, $_POST['customer_name']); $customer_address = mysqli_real_escape_string($con, $_POST['customer_address']); $customer_email = mysqli_real_escape_string($con, $_POST['customer_email']); $customer_phone = mysqli_real_escape_string($con, $_POST['customer_phone']); $total_pax = mysqli_real_escape_string($con, $_POST['total_pax']); $status = mysqli_real_escape_string($con, $_POST['status']); $order_at = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $total_amount = mysqli_real_escape_string($con, $_POST['total_amount']); $query="insert into bookings (`tour_id`, `tour_name`, `customer_name`, `customer_address`, `customer_email`, `customer_phone`, `total_pax`, `status`, `order_at`, `total_amount`)values ('$tour_id', '$tour_name', '$customer_name', '$customer_address', '$customer_email', '$customer_phone', '$total_pax', '$status', '$order_at', '$total_amount')"; mysqli_query($con,$query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ $message = '<p class="text-success"><i class="fa fa-check"></i> - Record Inserted Successfully</p>'; } } Can anyone please lend a hand with this? 2 Days at it now and ready to hit the Guinness.
Cheers, Dan I am looking at a website which will have a number of items on it advertised,such as:
businesses
jobs
property
etc
what I want to know is when designing the database would you have these in one table or a table for each?
Edited by brown2005, 14 October 2014 - 08:43 AM. This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=330078.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=317797.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=314170.0 |