Jump to content

jazzman1

Staff Alumni
  • Posts

    2,713
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by jazzman1

  1. But ... the time of the file exists and being created via stdin when the file has been created on the file server. You don't have to do this! To find all files created/modified exactly 3 days (72 hours) ago by NOW, you would use: find ${DIR} -name '*.tar.Z' -type f -mtime 3 More than 3 days: find ${DIR} -name '*.tar.Z' -type f -mtime +3 Less than 3 days find ${DIR} -name '*.tar.Z' -type f -mtime -3 PS: I will provide few examples if you don't understand something.
  2. The result is correct. You should organize the html output only in the way you want to be. Take a look at mine, using a SQL GROUP_CONCAT() function and Barand's examples, for others I didn't test them
  3. @oracle765, type into terminal - man gzip and look at examples. I looked at the log of your last attached file and saw this line, which is apparently wrong. /usr/bin/gzip -c -d -S "" /home/oracle765/public_html/feed/crazysales.csv.gz > /home/oracle765/public_html/feed/crazysales.csv If you want to unzip the file named "crazysales.csv.gz" and redirect the output to new one named crazysales.csv, try next: /usr/bin/gzip -c -d /home/oracle765/public_html/feed/crazysales.csv.gz > /home/oracle765/public_html/feed/crazysales.csv
  4. Aha, it's my typo: echo ilename_"dateQ".tar.Z So, use the unix find command to find all files in this particular directory older than 3 days and unzip them. Something like that jumped at the top of my head. #!/bin/bash DIR=$(dirname $0) find ${DIR} -name '*.tar.Z' -type f -mtime +3 | xargs tar -zxvf if [ $? -eq 0 ];then echo "Success"; else echo "Not files found" exit 0 fi Note: Make sure that tar -zxvf works for you or try gzip -d Are they provide a good compresson?
  5. Can I see the whole output of: echo ilename_"dateQ".tar.Z Why "Z" at the end?
  6. Try "tar", tar -zxvf path_to_the_file
  7. Take a look at here too, to learn a little more.
  8. Redesign your table structure according my dump file, then use the Barand's script. dump.sql -- -- Table structure for table `auto` -- DROP TABLE IF EXISTS `auto`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `auto` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL, `parent` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `auto` -- LOCK TABLES `auto` WRITE; /*!40000 ALTER TABLE `auto` DISABLE KEYS */; INSERT INTO `auto` VALUES (1,'AUTO',NULL),(2,'CAR',1),(3,'BMW',2),(4,'MERCEDEC',2),(5,'1 SERIES',3),(6,'3 SERIES',3),(7,'MOTORBIKE',1),(8,'500',7),(9,'600',7),(10,'A CLASS',4),(12,'C CLASS',4); PHP Script: <?php $conn = mysql_connect('localhost', 'userName', 'userPass'); $db_name = mysql_select_db('test'); $sql = "SELECT id, name, parent FROM `test`.`auto`"; $res = mysql_query($sql) or die(mysql_error()); while (list($id, $name,$parent) = mysql_fetch_row($res)) { $data[$parent][] = array('id'=>$id, 'name'=>$name); } //echo "<pre>".print_r($data, true)."</pre>"; // function to print a autos then its child nodes function displayHierarchy(&$arr, $parent, $indent=0) { $ind = $indent * 50; if(isset($arr[$parent])) foreach($arr[$parent] as $rec) { echo "<div style='width:300px; margin-top:5px; margin-left: {$ind}px; padding:5px; border:1px solid gray;'> {$rec['name']} </div>"; displayHierarchy($arr, $rec['id'], $indent+1); } } // call the recursive function displayHierarchy($data, null); Result:
  9. Barand was posted a solution using a recursive function.
  10. @oracle765 I'm out You don't know the basic things. Good luck.
  11. What's the common b/w Apache and Cron? Cron could be run without php, mysql and apache at all.
  12. Shared or dedicated server are you using to GoDaddy? PS: By LocalHost and LocalMachine I mean your home desktop, personal machine
  13. What linux distro are you running? Is it a remote or local machine?
  14. I don't know this exception using named place-holders He could create a set of random names for thouse named holders.
  15. Based on Ch0cu3r's example try to loop bindParam. Example: <?php $deleteIDs = array(1,2,3,4); // it's a post data from checkboxes $deleteIDsSQL = implode(',', array_fill(0, count($deleteIDs), ':id')); $sql = "DELETE FROM table_name WHERE `id` IN($deleteIDsSQL)"; $username = ''; $password = ''; $dbh = new PDO('mysql:dbname=dbName;host=hostAdress;charset=utf8', $username, $password); $stmt = $dbh->prepare($sql); foreach ($deleteIDs as &$id) { $stmt->bindParam(':id', $id, PDO::PARAM_INT); } $stmt->execute(); I don't have any problems with SELECT statement and bindParam in foreach, you shouldn't have a problem to delete multiple columns too. Note, the "&" symbol to the value inside foreach.
  16. Your first shuffled file into an array could be: $Songs = glob($SongsFolder."/*.mp3"); shuffle($Songs); echo $Songs[0]; // or am I wrong?
  17. To be able to run a file into a cron schedule make sure that the file has executable rights. For the issue with .csv file, do you try to import the data from mysql command client line? EDIT: What sql errors did you get running the script through the browser?
  18. Well, use the foreach only to display all shuffled file and get the link of the foreach if you want to display the current shuffled file with index 0 (zero)
  19. The shuffle function shuffles all files in the array. What did you mean by saying this:
  20. Check for actual errors, also. Put next functions on the top of this file: ini_set('display_errors',1); ini_set('display_startup_errors',1); ini_set('output_buffering','Off'); error_reporting(-1);
  21. Before doing anything with design of your website, make sure that the content has a valid HTML and CSS code. W3C Markup Validation W3C CSS Validation
  22. It's mine using GROUP_CONCAT(). DB-name = test DB-table = freaks <?php $username = 'lxc'; $password = 'password'; $dbh = new PDO('mysql:dbname=test;host=::1;charset=utf8', $username, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh->prepare("SELECT freaks.name,freaks.contact, GROUP_CONCAT(freaks.code ORDER BY freaks.code DESC SEPARATOR '<br />') as Code, GROUP_CONCAT(freaks.type ORDER BY freaks.type DESC SEPARATOR '<br />') as Type, GROUP_CONCAT(freaks.price ORDER BY freaks.price DESC SEPARATOR '<br />') as Price, GROUP_CONCAT(freaks.quantity ORDER BY freaks.quantity DESC SEPARATOR '<br />') as Quantity FROM test.freaks GROUP BY freaks.name"); $stmt->execute(); $outputs = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $outputs[] = $row; } $stmt = null; ?> <table border="1"> <tr><td colspan=6>Table</td></tr> <tr><td>Name</td><td>Contact</td><td>Code</td><td>Type</td><td>Price</td><td>Quantity</td></tr> <?php foreach ($outputs as $output): ?> <tr><td valign="top"><?php echo $output['name']; ?></td> <td valign="top"><?php echo $output['contact']?></td> <td><?php echo $output['Code']?></td> <td><?php echo $output['Type']?></td> <td><?php echo $output['Price']?></td> <td><?php echo $output['Quantity']?></td></tr> <?php endforeach; ?> </table> Result: <table border="1"> <tr><td colspan=6>Table</td></tr> <tr><td>Name</td><td>Contact</td><td>Code</td><td>Type</td><td>Price</td><td>Quantity</td></tr> <tr><td valign="top">Name 1</td> <td valign="top">xxxxxxxx</td> <td>GHTs<br />GHTd<br />GHT3</td> <td>Food<br />Food <br /> Food </td> <td>11<br />11<br />10</td> <td>2<br />2<br />2</td></tr> <tr><td valign="top">Name 2</td> <td valign="top">xxxxxxxx</td> <td>GHT3</td> <td>Food</td> <td>11</td> <td>2</td></tr> <tr><td valign="top">Name 3</td> <td valign="top">xxxxxxxx</td> <td>GHTs <br />GHTd </td> <td>Food<br />Food</td> <td>11<br />11</td> <td>2<br />2</td></tr> </table>
  23. http://www.php.net/manual/en/control-structures.foreach.php
  24. Please, don't double posting! You did edit the post when I've posted mine. I see the HTML content right now and what you wanted to do!
  25. Try, SELECT tbl.name,tbl.contact, GROUP_CONCAT(tbl.Code DESC SEPARATOR '<br />') as Code, GROUP_CONCAT(tbl.Type SEPARATOR '<br />') as Type,GROUP_CONCAT(tbl.Quantity SEPARATOR '<br />') as Quantity FROM database.tbl GROUP BY tbl.Name
×
×
  • 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.