PHP Form on WordPress (4.6.1) site - php

forgive me if is a basic question...
I am working on setting up a form on our new hosted Wordpress site - currently hosted inhouse on IIS/PHP/Wordpress server (I am not JR - but this stuff escapes me and would really like to figure it out!! I hate not knowing)
The OP that made the form / got it working is no longer around and I am sure there is a better way but this is what I have - a request form.
When I load the required files in the same path - copy the code from the WP page and paste it in the new Wordpress page - it loads without formating, the pick box doesnt look right and when I submit the form - I get these below PHP file errors. I can open the path in my browser and it exists - I see the class.GA_Parse.php file)
I checked execustion rights on the scripts - its set to execute - apart from that I dont know why it cant fine the files and that include_path I dont see via my hosting companys dir structure via FTP.
Any help would put me forever in your debt, I hope to be able to return the help, this site looks amazing!
Cheers,
Warning: require(/gaparser/class.GA_Parse.php): failed to open stream: No such file or directory in /home/comany/public_html/stage/forms/getfreetrial_v3.php on line 4
Warning: require(/gaparser/class.GA_Parse.php): failed to open stream: No such file or directory in /home/company/public_html/stage/forms/getfreetrial_v3.php on line 4
Fatal error: require(): Failed opening required '/gaparser/class.GA_Parse.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/company/public_html/stage/forms/getfreetrial_v3.php on line 4

PHP will load pages based on the disk location, not the URL. This means it's starting in the server's root / directory, not in /home/company/public_html/stage/forms. When including a file, either you have to use a relative link:
require('./gaparser/class.GA_Parse.php'); // starts in the same directory as the file
Or use PHP's server variable to get the document root:
require($_SERVER['DOCUMENT_ROOT'].'/gaparser/class.GA_Parse.php');
The paths may need to be tweaked depending on where the file actually is.

Related

Website not working properly since moving host. GeoIP Issue

My website used to work perfectly fine a few months ago. However, since changing host last month some parts of my website no longer work.
I am very sure the issue is related to GeoIP. My website requires the GeoIP php extension for it to work correctly. Both the old and new server have this extension enabled.
I get the following errors on my new server. Please note that the file "pdf_after_checkout_generator" is a custom made plugin.
PHP Warning: include(/usr/share/GeoIP/geoip.inc): failed to open stream: No such file or directory in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 18
PHP Warning: include(): Failed opening '/usr/share/GeoIP/geoip.inc' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 18
PHP Fatal error: Call to undefined function geoip_open() in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 20
I contacted my current host about this issue. I asked them what the file path is for the GeoIP extension on their server. They provided the following response (see bottom of post).
I would appreciate answers to the following questions:
I am not sure how to implement a solution. They are saying the file my website requires is not in their GeoIP extension file. Does this mean I need to install files (within the link they supplied) to my main wordpress site? then point my broken include code to the newly downloaded geoip.inc file?
I have no idea what this particular error is about. It is referencing PEAR, and I am not sure why.
PHP Warning: include(): Failed opening '/usr/share/GeoIP/geoip.inc' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 18
Hi there,
This would vary depending on what package you have I suspect, the
server I checked has the dat file (/usr/share/GeoIP/GeoIP.dat) present
but there is no PHP include file there.
The simplest fix would be to move the PHP dependency into the code
base of the application rather than relying on a globally shared
version. We don't as a rule install things like this globally as if it
was then updated and the API changed it would break everyone that
depended on its code.
You would need to check the .inc file on the old server to confirm but
this code is probably the code in this GIT repo so it would be simple
enough to move in to the base application -
https://github.com/maxmind/geoip-api-php
This has nothing to do with pear. The PEAR Net_GeoIP package has no geoip.inc file.
I guess that you have to put the source code of https://github.com/maxmind/geoip-api-php/ into /usr/share/GeoIP/ directory.

Error moving wordpress site

I`m trying to move my wordpress website from local computer to my new hosting. After compliting all guide steps I got an error:
Error
error: require(): Failed opening required '/home/casinost/websitename.online/www/wp-includes/home/casinost/websitename.online/www//load.php' (include_path='.:/usr/local/pear/php56') in /home/casinost/websitename.online/www/wp-settings.php on line 19
I understand that it might be some kind of path conflict of my old directory and new one, but how can I change this? Which file I need to modify to choose the correct directory?"
Wordpress always saves URLs as absolute file paths, including http:// or https://, the domain etc. This looks as if you have relatives filepaths in your wp-settings.php file which were not converted by whatever routine you used for the move to the other server. Compare those filepaths with all the other file paths/URLs which were converted correctly and change it accordingly.
Moving a wordpress site can be really hard, thats why there are some plugins for doing this with just a few clicks.
like: Duplicator
in the free version it should help you and do this task in a few minutes without headache.

Ninja Forms / File Upload issue after site migration

I've got a Wordpress site with a Ninja form that's using a file upload add-on. The form was working just fine on my Godaddy staging server. I migrated the site to another Godaddy account and the form stopped working. Being that the hosting accounts, and all other configuration, were virtually identical, I was stumped to understand what the problem could be.
Then I checked the PHP error logs and saw the following:
PHP Warning: mkdir(): No such file or directory in /new/server/wp-content/plugins/ninja-forms-uploads/.../pre-process.php on line 203
PHP Warning: move_uploaded_file(/OLD/server/wp-content/uploads/ninja-forms/tmp/xEgbu/ninja_forms_field_3332): failed to open stream: No such file or directory in /new/server/wp-content/plugins/ninja-forms-uploads/.../pre-process.php on line 209
PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpqrLDo5' to '/OLD/server/wp-content/uploads/ninja-forms/tmp/xEgbu/ninja_forms_field_3332' in /new/server/wp-content/plugins/ninja-forms-uploads/.../pre-process.php on line 209
PHP Warning: mkdir(): Permission denied in /new/server/wp-content/plugins/ninja-forms-uploads/.../processing/process.php on line 154
(FYI: the ellipsis is just a shorthand for unimportant parts of a file path.)
The thing to notice is the new/server/ and OLD/server/ conflict on the second and third PHP Warnings. For some reason, a Ninja Form script is attempting to move a file from a location on the old server to a location on the new server.
Is it possible that Ninja Forms, upon the initial installation, saved the full path of the server as a reference point in the database? If so, can that be found and adjusted without reinstalling Ninja Forms?
Thanks!
Mark
I suffered this too.
As at the end of https://ninjaforms.com/docs/file-uploads/
If you migrate from another server and the File Uploads path is
pointing to the older server location, you can deactivate then
reactivate your File Uploads and Ninja Forms plugins to reset the file
path.
Had the same issue. And while the suggested steps (of deactivating and reactivation File Uploads and Ninja Forms plugins by fiorebat) might have had some role to play but it didn't resolve the issue for me.
The problem was a really really silly thing .. UTF/Charset encoding issue. To solve that, actually type in % and/or any special characters on the Upload settings section of the File Uploads plugin.
I suspect this happens when both WP have different charsets.
Background: We were using a custom path/destination for File Uploads with %year%/%Mmonth% in the path. When we hardcoded the path to say 2019/7 it worked fine. So next, we manually typed in % (or copy from the samples show on the same page) and it custom/dynamic paths worked as well.

Viewing PHP properly with my Localhost using XAMPP

This is my first attempt at using a localhost while editing PHP website files (I'm a HTML girl, but have been asked to make some aesthetic changes to a PHP site).
I've installed XAMPP on my Mac already and configured it (as far as I know). MySQL Database, ProFTPD, and Apache Web Server are running. I've succeeded at viewing a simple index.php file from the htdocs files using localhost/index.php. I've placed the entire website directory (named newsite) inside the htdocs folder. When I attempt to view the website in Firefox or Safari via localhost/newsite/index.php I get this message in the browser:
Warning:
include_once(/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc):
failed to open stream: No such file or directory in
/Applications/XAMPP/xamppfiles/htdocs/newsite/index.php on line 2
This is referring to a block of PHP at the beginning of the index.php document. I've checked, the simplepie.inc file is in file inc under file newsite. If I try go around it by commenting out that section of code and any related calls, the browser goes blank. Can anyone please tell me what else I need to do to just view these files via localhost?
Okay, this is simple but might be complex. So you state:
I've checked, the simplepie.inc file is in file inc under file
newsite.
And then the error states:
Warning:
include_once(/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc):
failed to open stream: No such file or directory in
/Applications/XAMPP/xamppfiles/htdocs/newsite/index.php on line 2
So the error is being thrown because it is trying to read this file:
/Applications/XAMPP/xamppfiles/htdocs/inc/simplepie.inc
But it is located here:
/Applications/XAMPP/xamppfiles/htdocs/newsite/inc/simplepie.inc
What are the actual contents of that include_once?
Since you will probably be moving this site from one place to another, I recommend doing this. I am assuming I know what your include_once looks like, but the general concept holds true.
First, in your index.php or main config/init file (if you have one) add this line:
$BASE_PATH='/Applications/XAMPP/xamppfiles/htdocs/newsite';
Then for your include_once change it to read:
include_once($BASE_PATH . '/inc/simplepie.inc');
Basically that will do the equivalent of changing the include_once to this:
include_once('/Applications/XAMPP/xamppfiles/htdocs/newsite/inc/simplepie.inc');
But the flexibility of using $BASE_PATH is it allows you to change the general site $BASE_PATH in one place & then use it wherever in your site you wish.

Why am I getting include() and require() errors from one directory of my site and not another?

Total newbie here, so take it as you will...
I'm doing a site upgrade right now, and everything works fine except...
I have a WordPress installation in a subdirectory, and now that I've brought the main site live, I'm getting
include(/settings.php) [function.include]: failed to open stream: No such file or directory
and
include() [function.include]: Failed opening '/settings.php' for inclusion (include_path='.:')
on includes from within the subdirectory. I've played with setting different include_path settings, I know for sure the files are there (they are being included with no problems from the root directory), and I'm changed no permissions or anything during the rollout of the site.
Please let me know if this question is improper, or misplaced, or too vague, or what have you - first post after months of googling and lurking.
thanks in advance!
You're likely using php in a chrooted environment, so the root path of the server doesnt match that of the script.
Regarding the variables scope issue, could you post some sample code?
"/settings.php" points to the root of your server. It should be "settings.php" if it is on the same path and it should be in quotes.
Cheers
I would recommend adding define('WP_DEBUG', true); to your wp-config.php file and report back with more information. Make sure to undo this any you grab the info for debugging as having this on a live site could be a security risk. I just search my whole WP directory for include( "/settings.php" ); and could not find anything, which makes me think that it make be an issue with a plugin, theme, or other custom code. You could troubleshoot this by disabling all of your plugins, seeing if the site works again, and then painstakingly enabling your plugins individually until you find the culprit.
Does the error message you get point to a specific file and line number? That can help debug the problem.

Categories