PHP script not looking in includes folder - php

I have a new install. Ubuntu 22.04, Apache2, PHP 8.1 and I'm trying to use PHPMailer. My test page with phpinfo all looks good and shows the includes directory /usr/share/php. My form and script are in a subfolder of my document root and it loads fine. But when I fill out the form and the script starts it errors out unable to find PHPMailer. It's only looking in the subfolder the script is in, not the global includes directory. I don't want to put the mod in every form folder and I know it's supposed to work from the includes folder. Is this an Apache or php config issue? Or something I have to specify in the vhost?

Just verifying and closing out with the answer
I found the issue early today. Thanks to bad/tired eyes, I wasn't seeing the leading dot so it was looking for ./usr... Once i fixed that i was able to sort out the Ubuntu method of calling it from the libphp-phpmailer pkg autoload.php. I was able to get the script working with a few code corrections. The only thing I didn't sort out was PHPMailer:ParseAdresses but i only had a few recipients for this form so it wasn't that big an issue. My form is back online and my managers are happy 😊

Related

PHP can't file contact.html, but it shouldn't exist? (Smarty Engine)

I've got a legacy PHP project to fix a thing or two. I've downloaded it via FileZilla and served it on my local machine with a local copy of the database. The project is exactly the same with the live one, yet the live one can open the url/contact.html but on my machine it says no such file is found. All other pages go for url/categories/ or url/products/ so I've tried altering the url but no use.
All the other pages within the site are simple: one .php controller one .php model and one .tpl smarty template view. Requiring no .html at all. But this one is somehow different. The .htaccess file is exactly the same as the live version. I've tried adding a rewrite rule to direct every .html to .php but didn't work. I'm lost and out of options, please help? It doesn't even have to be an answer,"Try looking into that" would work too.
I'm working via XAMPP on windows, and I've configured the https:// to http:// on my project but that's all. Even hidden files are checked and confirmed.
have checked that contact.html is a static file (like a real existing html file?)
is there some kind of "routing" within the PHP of the project? If there is route urls might be really anyware.. in the mysql database, redis, a json file and whatnot.. have seen them all.
try to debug where and how it works on the "production" server by using some logging to a file edit the file through filezilla and log to a 'mylog.log' file until you find out what is going on.. or if the site is not used all the time by clients - you can just try to echo stuff to figure out how this exact /contact.html works

PHP 5.5 -> 5.6: Include not working any more (Codeigniter)

I´m moving an application from a PHP 5.5 server to a PHP 5.6 server. The application is based on Codeigniter 2.2.
On the old server I had something like this in my views to include other template parts:
include('header.php');
This simple and direct include works like a charm on the old server.
On the new server I get the exception, that the file for inclusion could not be found.
I found out, that the PHP preprocessor tries to grab the file from the linux include paths and also from the "system/core" directory. But not from the directory where the view itself is located.
I´ve not idea what makes the difference between these two systems... Has anybody an idea where I can search for the issue?
Check the file path. Whether its inside some other folder or not.
Also can try with
$this->load->view('header.php');
or can load header in Controller as well
As well there are some useful keyword.
APPPATH - Outputs application path. Ex application/
Thanks guys for all your input - I´ve already tried most of these debugging attempts.
Now I digged a little deeper and found the reason for my problems. The short_open_tag directive in PHP caused the issue. Cause this new server had some slight differences in php.ini.
In core/loader.php Codeigniter tries to replace short open tags with normal tags, if the .ini setting for short_open_tags is disabled. For any reason this replacement isn´t working as expected and that caused my issues.
So if anyone has the same issue after moving a Codeigniter installation from one machine to another, that might be a point where you can start.
Thanks to all of you,
Michael

After changing filename from index.html to index.php my project is no longer served with MAMP

I'm trying to do some PHP learnin' but I've run into a road-block. I have MAMP installed and I am successfully serving my project files locally. However, after renaming my index.html file to index.php, the page is no longer served.
url is: localhost/projectfile/
I can rename the file back to index.html and the page will serve up again but this means my php code won't run.
I've tried digging around MAMP to see if there is some information/ setting that could help but I'm not finding a solution. It would be great if anyone has info on how this could be solved. Thanks!
You will find all the "start page" stuff in MAMP/bin/mamp (e.g. the English language page is MAMP/bin/mamp/English/index.php).
This is due to the following line in MAMP/conf/apache/httpd.conf:
Alias /MAMP "/Applications/MAMP/bin/mamp"
Refer Where is the index.* file that is served as the MAMP start page URL?
For anyone viewing this post- I must have edited a config file in the wrong way. I uninstalled MAMP and reinstalled and everything seems to be working properly now.

Local xampp wordpress installation - cannot find wp-blog-header.php

I'm working locally with XAMPP and Wordpress and I'm struggling with what is probably a very basic config issue. I'm not a professional IT guy, just a hobbyist hacker so I apologise in advance if I'm being a bit dumb but hopefully somebody can kindly offer some assistance here.
I've installed xampp locally on my iMac. I've then installed wordpress using the xampp wordpress installation package. Both seem to be working fine. To test the web server I created a simple .php test file and this generated the expected output when I entered "localhost/hello.php" into my browser. As far as wordpress is concerned entering "localhost/wordpress" gives me access the local wp interface to create and edit posts, change display settings etc etc. So far so good...
Now I want to create a new .php file that includes the instruction:
require('XXX/wp-blog-header.php')
where the "XXX" is obviously the relevant directory path for the wp header file.
I cannot find this file, or indeed local wordpress files, anywhere (and I've searched extensively). In the "home" location for "localhost" (which I know from my "hello.php" test) there isn't even a wordpress directory so I'm totally puzzled as to how typing "localhost/wordpress" in my browser is accessing the local wp installation or how to go about determining the correct directory path for the wp header file I'm looking for?
I do understand that with this stack a great deal of info will either be generated on the fly, or stored in the local mysql database as opposed to the file structure, but I thought I would find some reference or alias somewhere to help me trace this through and determine what path to include in my .php file for wp-blog-header.php.
I've searched this forum and while there are several related questions I haven't found anything that helps me with this particular issue.
Thanks vm,
Ian
The location of your Wordpress files is:
/Applications/XAMPP/xamppfiles/apps/wordpress
Ok I found the path I needed and (partially) understand why I couldn't locate it. As Scriptonomy helped me identify the Wordpress files are held at:
/Applications/XAMPP/xamppfiles/apps/wordpress
While my test.php file is held at:
/Applications/XAMPP/xamppfiles/htdocs/test.php
The reason I couldn't locate either wp-blog-header.php or wp-load.php is because these there is an another "htdocs" sub-dir under the wordpress install location i.e.:
../apps/wordpress/htdocs
However I (as user "admin") don't have access to read this directory and so couldn't see the contents and therefore couldn't find the files. The permissions on the directory belong to "daemon" which I guess was the XAMPP installer package? Setting the directory path in my test.php file to:
../apps/wordpress/htdocs/wp-load.php
somehow the web server (?) can read the file (even though I can't see it myself via the Finder application) and so the code is now giving the expected result.
So problem solved even if I don't quite understand the solution!
Thanks for replies which helped me eventually get to a solution!
Cheers,
Ian

Call to PHP prints source, doesn't run when called from another file

I have a quick question that I can't figure out. I've tried searching Google and following examples, but I can't find anything.
I have an HTML form that I'm trying to process with a PHP file, but when I submit the form, it merely prints the source of the PHP file, it doesn't execute it. If I run the PHP file by itself (not indirectly through the HTML button), it works fine.
HTML form header:
<form id="registrationform" name="registrationform" method="post" action="processregistration.php">
Submit button:
<button type="submit" value="Submit" >Create</button>
The PHP form is just <?php print "Hello"; /?
Again, it runs fine if I just run the PHP file, but prints the PHP file (doesn't run) when it gets called through the HTML form.
Any help is appreciated.
edit-Running locally through Coda
edit-Here is the output that I'm getting:
Output when the PHP is called through an HTML action:
</php
print "Hello";
?>
Output when I run the PHP directly through Coda:
Hello
I had the same problem and just fixed it on my coda version 1.7.4
I installed MAMP on my mac and set up the apache path under MAMP preferences to the folder where my sites are located;
/Users/yourUserName/Sites
this points MAMP's 'http://localhost:8888' address to your sites folder, if you paste that on your browser you'll now see your sites folder's content in the browser.
then, all you do is point the local site's connection settings to the site you are testing;
I was going to post an image, but I'm new to the site and wasn't allowed.
Under my site's preferences i set up the addresses as follows;
Root URL : 'http://localhost:8888/yourSiteRootFolder/'
Local URL : 'http://localhost:8888/yourSiteRootFolder/'
Remote Root : /yourSiteRootFolder/
Local Root : /Users/amartinez/Sites/yourSiteRootFolder/
I hope this is related to the problem you're having and helps you fix it.
Line #19 from Coda 1.6 Release notes:
Coda no longer tries to locally
preview a remote PHP file while
editing/previewing
Listed under "Improvement" - doubt they brought it back for the 1.7 release.
I'm running Apache2/PHP5 10.5.8 OS X (no problem reproducing your issue with Coda)
Even when running my form.html and post.php files from /Library/WebServer/Documents folder.
My sample files work fine in the Apache env....I just needed to run them through Coda to "break" them. :-)
Are you sure the html file and the php script are on a server with php support enabled?
I've never used Coda, but you need to be running it through a server (e.g. Apache + PHP). You cannot just open the file itself within Windows.
Try looking at xampp as a quick server for testing.
If it works properly, you should be viewing the PHP file on something like http://localhost/test.php instead of file:///something/test.php.
This may be because you don't have PHP installed on your server. I would check to make sure that your hosting package included PHP, pre installed.
Here are some resources to get you started with that, if not installed:
http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml
http://www.php.net/manual/en/install.php
http://www.w3schools.com/PHP/php_install.asp
Edit: actually, I think I may have found it.
If you look at the starting PHP tag, you have a slash instead of a ?. If that's in your script, just change that to <?php. But it may not be, it could be that's just question format-ing.

Categories