Jump to content

raphael75

Members
  • Posts

    46
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by raphael75

  1. It turned out to be a non-breaking space that was on the line ($b == false) && after the 2nd &. Removing that fixed the issue.
  2. Here is my PHP code: <?php $a = 76; $b = true; $c = 0; $d = 500; $check = ( ($a > 0) && ($b == false) && ($c == 0) && ($d > 0) ); echo '[' . $check . ']' . "\n"; //echoes [] // ------------------------------- $a = 76; $b = false; $c = 0; $d = 500; $check = ( ($a > 0) && ($b == false) && ($c == 0) && ($d > 0) ); echo '[' . $check . ']' . "\n"; ?> This generates this error: PHP Fatal error: Uncaught Error: Call to undefined function () in /home/abc/code/php_test/test_boolean.php:26 Stack trace: #0 {main} thrown in /home/abc/code/php_test/test_boolean.php on line 26 I can't figure out why this error is occurring. Why does changing $b to false make it think it's a function call? I get this error if I run it in the browser or on the command line. However, testing it in different online php testers doesn't cause an error and produces the expected output. I don't know why this is causing an error on my local. I tried with both php7.3.31 and php 8.0.12
  3. Zip should support 64-bit archives. If you can't get it to work, you could try using WinRAR for Linux and call it from exec().
  4. PHP runs under a certain user account. On Linux it's usually www-data (which is what apache usually runs under, and thus PHP). But this could be different. On Windows/IIS it's usually IUSR_MACHINE. Whatever the user account is, it has to have permission to access the file.
  5. Irfanview has a lot of advanced batch operations: http://www.irfanview.com/
  6. Should this line: if (empty($date)) { be if (empty($data)) { ?
  7. It's also possible that enclosing the <h3> inside <p> is causing problems, especially if the <p> is floating. I'm pretty sure it's a CSS/HTML issue, because all the data is there in the code in the screenshot. I think all the rows are on top of each other due to CSS positioning.
  8. Different browsers are picky about the syntax of the HTML tags. values should always be enclosed in double-quotes, so where you have: <img src='yuklemeler123.jpg'> or <a href=detay.php?id=2> change it to <img src="yuklemeler123.jpg"> or <a href="detay.php?id=2">
  9. Replace what you have with this: if(isset($_GET['dir'])){ echo '<title>' . $_GET['dir'] . '</title>'; } else{ echo '<title>A Star Maths and Physics Notes</title>'; }
  10. Are you working on a windows- or linux-based system?
  11. Have you added it to the example page (http://astarmathsandphysics.com/notes/?dir=gcse-physics) yet?
  12. Try this: if($this->files) { $count = 0; foreach ($this->files as $file) { $cur_file = $this->location->getDir(false, true, false, 0).$file->getNameEncoded(); $finfo = finfo_open(FILEINFO_MIME_TYPE); $cur_mime_type = finfo_file($finfo, $cur_file); if(($cur_mime_type == 'image/gif') || ($cur_mime_type == 'image/png')){ continue; } $row_style = ($row ? "one" : "two"); print "<tr class=\"row ".$row_style.(++$count == count($this->files)?" last":"")."\">\n"; print "<td class=\"name\">\n"; print "\t\t<a href=\"".$this->location->getDir(false, true, false, 0).$file->getNameEncoded()."\""; if(EncodeExplorer::getConfig('open_in_new_window') == true) print "target=\"_blank\""; print " class=\"item file"; if($file->isValidForThumb()) print " thumb"; print "\">"; print $file->getNameHtml(); if($this->mobile == true) { print "<span class =\"size\">".$this->formatSize($file->getSize())."</span>"; } print "</a>\n"; print "</td>\n"; if($this->mobile != true) { print "<td class=\"size\">".$this->formatSize($file->getSize())."</td>\n"; print "<td class=\"changed\">".$this->formatModTime($file->getModTime())."</td>\n"; } if($this->mobile == false && GateKeeper::isDeleteAllowed()){ print "<td class=\"del\"> <a data-name=\"".htmlentities($file->getName())."\" href=\"".$this->makeLink(false, false, null, null, $this->location->getDir(false, true, false, 0).$file->getNameEncoded(), $this->location->getDir(false, true, false, 0))."\"> <img src=\"?img=del\" alt=\"Delete\" /> </a> </td>"; } print "</tr>\n"; $row =! $row; } }
  13. From a high-level view, it is usually helpful to parse a form first with javascript and make any adjustments you need to. This will help the PHP script that will process the form to enter the correct data. Usually if I have a series of radio buttons or a checkbox, I will have the javascript create a delimited list or set 1/0 values, respectively, in hidden form fields if necessary, before submitting the form. Once you get the right data going to the PHP and it is able to insert the form data in the database, the other half is displaying that data. When the page that will display the form data loads, in some cases you load all the data with 1 SQL statement, or possibly more than one depending on the complexity of the data and how it is structured. If you store true/false values in your database as 1/0, then when PHP is building the page it needs to look for 1/0. It all depends on how you decide to store it. If you have a series of radio buttons, you would usually have a loop to create the HTML. It would set the id (<input type="radio" id="rad_0"... >, <input type="radio" id="rad_1"... >, etc.) of each <input> and as it's looping through, look for the selected value from the database. How you store that is your choice. I hope this helps.
  14. Just a guess, but is this code on the index.php page? If so, is there a condition that could cause the CheckLogin function to fail on that page? If so, it could set up an infinite loop where the index.php is redirecting back to itself.
  15. You should be able to do something like this: if($this->files) { $count = 0; foreach ($this->files as $file) { $filename_parts = explode('.', $file); //break up filename into an array $extension = $filename_parts[(count($filename_parts) -1)]; //get the last array element - the extension if(($extension == 'gif') || ($extension == '.png')){ //if the extension is .gif or .png continue; //go to the next file } $row_style = ($row ? "one" : "two"); print "<tr class=\"row ".$row_style.(++$count == count($this->files)?" last":"")."\">\n"; print "<td class=\"name\">\n"; print "\t\t<a href=\"".$this->location->getDir(false, true, false, 0).$file->getNameEncoded()."\""; if(EncodeExplorer::getConfig('open_in_new_window') == true) print "target=\"_blank\""; print " class=\"item file"; if($file->isValidForThumb()) print " thumb"; print "\">"; print $file->getNameHtml(); if($this->mobile == true) { print "<span class =\"size\">".$this->formatSize($file->getSize())."</span>"; } print "</a>\n"; print "</td>\n"; if($this->mobile != true) { print "<td class=\"size\">".$this->formatSize($file->getSize())."</td>\n"; print "<td class=\"changed\">".$this->formatModTime($file->getModTime())."</td>\n"; } if($this->mobile == false && GateKeeper::isDeleteAllowed()){ print "<td class=\"del\"> <a data-name=\"".htmlentities($file->getName())."\" href=\"".$this->makeLink(false, false, null, null, $this->location->getDir(false, true, false, 0).$file->getNameEncoded(), $this->location->getDir(false, true, false, 0))."\"> <img src=\"?img=del\" alt=\"Delete\" /> </a> </td>"; } print "</tr>\n"; $row =! $row; } }
  16. I'm using a PHP script from the command line to copy files from a mapped drive on a remote computer to a folder on the local computer where PHP is running. I get an "Access is denied (code: 5)" error. When PHP runs from the command line, is it using the same user account it runs with when it runs in the browser? How can I tell if the access is denied on the remote side or the local side? What account would need to have read/write permissions set? Thank you!
  17. Figured it out - floating point math isn't straightforward. Had to use number_format to round to 2 decimal places.
  18. So I have 2 arrays of numbers, and this: $variance = array_sum($db_tot) - array_sum($cr_tot); If the sum of each array is the same, why does PHP return -1.8189894035459E-12? Why wouldn't it be 0 (positive 0 or just 0)? Thanks!
  19. Figured it out - gotta escape the double \'s <?php $cmd = 'net use t: \\\\comp1\folder /u:dom\user pwd'; $cmd .= 'net use u: \\\\comp2\folder /u:dom\user pwd'; exec($cmd, $out, $ret); ?>
  20. I have this code to map two network drives: <?php $cmd = 'net use t: \\comp1\folder /u:dom\user pwd'; $cmd .= 'net use u: \\comp2\folder /u:dom\user pwd'; exec($cmd, $out, $ret); ?> When exec() runs I get this: System error 67 has occurred. The network name cannot be found. and $ret echos 2 I've done some research but I can't figure out what is causing System error 67. Any help is greatly appreciated.
  21. I did some more testing. In the batch file I put in: dir O:\path\to\files > dir.txt net use > net_use.txt When I run the batch file manually both dir.txt and net_use.txt look right. However, when I run the scheduled task, dir.txt is empty and net_use.txt shows "unavailable" for the status of each mapped drive on the computer. What would cause the status to be "unavailable"?
  22. Here is our setup: Server A - Windows 2008 R2 PHP script on server A that copies files Drive O: on computer B - Windows computer contains source files Drive V: on computer C - Debian Linux computer target folder We have the PHP script on server A that copies files from the mapped drive O: (on computer B) to the mapped drive V: (on computer C). The script works perfectly when run manually from the command line. However, when the same PHP script is run from Task Scheduler it can't see the folders on drive O:. I had it echo out is_readable and is_writable on the O: drive folders, and when run from CLI they both return 1 but when run from task scheduler they return 0. I also had both echo out get_current_user and they both return the same user. The scheduled task is set to the same user the CLI one is, and is set to run with highest privileges. The scheduled task calls a batch file that then calls the php file. This is the contents of the batch file: @echo off start "" /b /separate php -f "d:\scripts\get_files.php" If I run the batch file manually the script works, so it definitely seems to be something with the scheduled task itself, but I can't figure out what. Any help would be greatly appreciated. Thank you!
  23. Thanks for the tips! I will try all of those and see what I can find.
×
×
  • 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.