Search found 622 matches

by NigelRen
Thu Sep 01, 2016 11:16 am
Forum: PHP coding => General
Topic: URL help
Replies: 0
Views: 708

Re: URL help

If you share the code you have so far then someone may be able to see what's going on.
by NigelRen
Mon Aug 29, 2016 10:02 pm
Forum: PHP coding => General
Topic: $zip->extractTo('/data1/')
Replies: 3
Views: 1040

Re: $zip->extractTo('/data1/')

I know this must be frustrating, but it's difficult without having the full system to look at to know what is going on. Are the two scripts in the same directory? As you are using relative paths, it could mean that one would find the archive, the other doesn't. Using a simple fopen would have the sa...
by NigelRen
Sat Aug 27, 2016 12:01 pm
Forum: PHP coding => General
Topic: Cannot call lambda when stored as a static variable
Replies: 0
Views: 1045

Re: Cannot call lambda when stored as a static variable

Have you tried...

Code: Select all

(self::$lambda)();
by NigelRen
Sat Aug 27, 2016 11:55 am
Forum: PHP coding => General
Topic: Why namespace in a folder does not work?
Replies: 0
Views: 823

Re: Why namespace in a folder does not work?

Two things - should you be 'including' the sanza/Sanza.php file at some point? When you use 'include' it can be missing and only generates a warning, whereas 'require' will give an error if an include file isn't found. I can't understand why you would need this sort of thing and prefer use 'require_...
by NigelRen
Wed Aug 24, 2016 12:30 pm
Forum: PHP coding => General
Topic: fatal error:Call to a member function appendChild() on null
Replies: 1
Views: 929

Re: fatal error:Call to a member function appendChild() on null

Also check the permissions of the file, it could be that the XAMP server is running as a different user that has created the file. Make sure the file is readable by ANY user.
by NigelRen
Wed Aug 24, 2016 12:22 pm
Forum: PHP coding => General
Topic: PHP 7.0 is not including my code folks!
Replies: 0
Views: 596

Re: PHP 7.0 is not including my code folks!

I tend to use directories relative to the current file - so...

Code: Select all

require_once dirname(__FILE__).'/../Database.php';
This means I'm starting from a known point (the directory of the current file) and then work from there. It's not dependant on web addresses or fixed server structures.
by NigelRen
Mon Aug 15, 2016 10:10 pm
Forum: PHP coding => General
Topic: Ajax success function isn't fired with require instruction
Replies: 1
Views: 772

Re: Ajax success function isn't fired with require instruction

I would also look into using 'require_once' as well, this ensures that a file is only ever put into the source once only and can avoid some times when a file is included all over the place. Have a read of http://php.net/manual/en/function.include-once.php which gives you some ideas of why you'd want...
by NigelRen
Mon Aug 15, 2016 9:59 pm
Forum: PHP coding => General
Topic: PHP File Upload Issue
Replies: 15
Views: 4222

Re: PHP File Upload Issue

Can you try setting the upload directory to an absolute path ( so c:\inetpub\wwwroot\web\Upload2\uploads ) and see if that helps. This can ensure that it's using the right place, you can use something like dirname(__FILE__) and make the directory relative to the script your using ( a better long ter...
by NigelRen
Mon Aug 15, 2016 2:10 am
Forum: mySQL & php coding
Topic: Capture form data to mail and show it's content
Replies: 0
Views: 899

Re: Capture form data to mail and show it's content

If you look in the routine that send the e-mail, there should be a POST variable that has the persons name in it. It could be that the POST variable is something like $_POST["firstname"], so just check what the actual field it is using and it should be OK.
by NigelRen
Mon Aug 15, 2016 2:01 am
Forum: PHP coding => General
Topic: Timeout issue with scripts
Replies: 0
Views: 699

Re: Timeout issue with scripts

If this is a background task, you could try using some for of queue to list a set of tasks to do and then run a script as a background task (or have a look at something like http://php.net/manual/en/intro.gearman.php - not something I've tried). There are other ways of achieving this, depending on t...
by NigelRen
Mon Aug 15, 2016 1:55 am
Forum: PHP coding => General
Topic: Calling script
Replies: 0
Views: 716

Re: Calling script

I'm not sure if the splitting the script because of timing out will help - as the overall script itself will time out. Perhaps you could find out what is taking the longest in your script and try and optimise it. I've not tried it myself yet, but have a look through https://xdebug.org/docs/profiler ...
by NigelRen
Mon Aug 15, 2016 1:47 am
Forum: PHP coding => General
Topic: PHP File Upload Issue
Replies: 15
Views: 4222

Re: PHP File Upload Issue

The problem you were having was a permissions problem (I think) and it could be that the directory that you are trying to upload to doesn't allow other users to write to it. The PHP scripts may be using a different user than what you are using to create the code (on *nix it uses www-data). So first ...
by NigelRen
Sun Aug 07, 2016 12:04 am
Forum: PHP General
Topic: What to learn - opinions wanted
Replies: 1
Views: 912

What to learn - opinions wanted

Hi I've been out of IT for a few years and thinking about getting back into it as a PHP developer. I've been doing stuff on here for a while and started to think it may be a viable option to work in PHP. What I want to try and think about is what should I learn to give myself the best opportunity to...
by NigelRen
Tue Aug 02, 2016 12:01 am
Forum: PHP coding => General
Topic: Email sent confirmation
Replies: 0
Views: 891

Re: Email sent confirmation

If your mail has been submitted, it just jumps to index.html, but if it doesn't get sent it jumps to index.html. There is nothing in this to flag if the mail has been sent or not (you try using a variable but this isn't maintained across the page transition). If you passed a parameter along with the...
by NigelRen
Mon Aug 01, 2016 4:11 am
Forum: PHP coding => General
Topic: How to write one unsigned byte value to a file at a given offset?
Replies: 1
Views: 989

Re: How to write one unsigned byte value to a file at a given offset?

A quick test produced the following code... <?php $file=fopen ("test.txt", "cb"); $a=chr(0b1); fseek($file, 2); fwrite($file,$a,1); fclose($file); The one thing which makes a difference from my first attempt is using the 'chr()' function. What was happening is that PHP was being toooooo helpful and ...
by NigelRen
Sun Jul 31, 2016 11:42 pm
Forum: PHP General
Topic: Naming conventions : should i name my functions differently ?
Replies: 1
Views: 1580

Re: Naming conventions : should i name my functions differently ?

Using a different naming standard to distinguish your own code is IMHO a bad idea. It assumes that you do not understand the code and that the name of the function itself doesn't clearly state it's purpose. If you think there would be some confusion, try using namespaces to differentiate the code. O...
by NigelRen
Fri Jul 15, 2016 10:31 pm
Forum: PHP coding => General
Topic: The perfect Php form
Replies: 1
Views: 623

Re: The perfect Php form

One thing that is usually missing in most code is any form of error checking and reporting. For example, the connection isn't checked after being made. From the online manual, if you add... if (!$conn) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_e...
by NigelRen
Fri Jul 15, 2016 1:54 am
Forum: Other Database Engines
Topic: convert a .php file to .dll
Replies: 3
Views: 5312

Re: convert a .php file to .dll

It would be as much work as having to rewrite it in C/C++ from scratch. As mentioned in one of the other posts, it would be easier to set up PHP to run somewhere locally and do it that way.
by NigelRen
Mon Jul 11, 2016 10:05 am
Forum: PHP Scripts
Topic: Some data loading classes/scripts
Replies: 0
Views: 1926

Some data loading classes/scripts

I've been messing around with the idea of how to 'intelligently' load data into a PHP class. With a bit of inspiration from Apache Camel and the use of annotations I came up with this test set. Would be interesting to get others viewpoints on this - it's still a work in progress and as I develop it ...
by NigelRen
Sat Jul 09, 2016 3:23 am
Forum: mySQL & php coding
Topic: Convert query to prepared statement and execute.
Replies: 0
Views: 1041

Re: Convert query to prepared statement and execute.

When running something like the prepare statement, there is always the possibility that it will return 'false' if something fails. So if your code had a bit to check that if this is false then put out the error, it would help in debugging your code. If this case it's a trivial thing that you have 'G...
by NigelRen
Sat Jul 09, 2016 2:53 am
Forum: PHP coding => General
Topic: Fatal error: Uncaught Error: Call to a member function getIterator() on null in C:\php\awsdiskcount.php:10 Stack trace:
Replies: 2
Views: 1173

Re: Fatal error: Uncaught Error: Call to a member function getIterator() on null in C:\php\awsdiskcount.php:10 Stack tra

It should be easy enough to Google this sort of thing... Using 's3client php getIterator' as the search gives http://docs.aws.amazon.com/AmazonS3/latest/dev/ListingObjectKeysUsingPHP.html as the first result, which has use Aws\S3\S3Client; // Instantiate the client. $s3 = S3Client::factory(); $bucke...
by NigelRen
Mon Jul 04, 2016 2:06 am
Forum: mySQL & php coding
Topic: Displaying Fields On Page
Replies: 2
Views: 1571

Re: Displaying Fields On Page

One of the things that you have to get used to is checking error logs and how to use them effectively. They provide all sorts of valuable information when things go wrong and should be the first place you look at when a page doesn't load.
by NigelRen
Sat Jul 02, 2016 11:31 pm
Forum: PHP Installation
Topic: PHP install goes bust during upgrade
Replies: 0
Views: 1730

Re: PHP install goes bust during upgrade

You may be able to just uninstall the old config, if you know how to re-install all of the components that you need using sudo apt-get -y purge php.* The problem may be that when 5.5 came along, some of the main database libraries which were commonly used were deprecated and so this could mean havin...
by NigelRen
Sat Jul 02, 2016 12:07 am
Forum: PHP coding => Images
Topic: Applying empty a href links to menu items with sub-menus.
Replies: 0
Views: 1317

Re: Applying empty a href links to menu items with sub-menus.

I would have thought that parentid has nothing to do with this menu item having no child menu items. All it means is that this is a root menu item. Would it be better to read in all the menu items, then go through them all and flag each menu item that is referred to (via a parentid). Then any menu i...
by NigelRen
Fri Jul 01, 2016 11:58 pm
Forum: PHP coding => Images
Topic: sending Images to PHP script from C# code in UWP application
Replies: 0
Views: 1377

Re: sending Images to PHP script from C# code in UWP application

Google (I hate to say this) is your friend - have a look at http://stackoverflow.com/questions/5664 ... -form-data which might cover what your after.