php login script error - php

I have this login script working just fine on one server but not on other and coudn't figure out why.
include_once 'include/processes.php';
$Login_Process = new Login_Process;
$Login_Process->check_status($_SERVER['SCRIPT_NAME']);
and the third line won't display the server status, the code display on my web page, and didn't go to main page. any idea may cause the issue.
thanks.

The third line isn't working, most likely, because you have a Fatal Error being generated somewhere as a result of this line:
$Login_Process = new Login_Process;
Either use ini_set to change the errors being displayed, or set up an error log. You basically need to know what the errors are, and then you can deal with them.
It could be many things, some of which may be the configuration.
The first thing I would check is the PHP version. Make sure that nothing in your scripts or your php.ini file conflict with the version of PHP you're migrating to.
After that, go through the functions you're calling and make sure nothing is deprecated in PHP on the second server.

Related

Notice warning from PHP in Symfony uploading file

I have a form that allows upload three files at the same time but just one is required. That works fine, my only problem is the following: if I upload three files I haven't any problem but if I upload one or two files (leaving two or one files empties) I obtain the following notice:
Notice: No file uploaded in Unknown on line 0
As much as empty files. The files are uploaded properly without any other problem, but I want remove that notice... or unless hide it, although I prefer remove it. I tried to hide it using
error_reporting(0);
and
ini_set('display_errors',0);
but neither of two worked...
It is the first time that I have problem, if someone could lead me I'd be very grateful due to that I am stuck with it.
If you are having the same problem as me, check with phpinfo() if you are using a debug version of PHP. If you see that Debug Build has a value of yes, your problem will be fixed if you install a live version of PHP instead of a debug version
The Error itself is caused by running a Debug version of PHP 7, see the bug report. As noted by HPierce because it was a Debug build it overrides the usual PHP settings for error_reporting. However as the Original question is actually about how to hide certain [expected] error messages (Notices), my answer is to this detail specifically.
Kevin, the attempted ways to hide errors you've listed in your question would normally work on non-debug PHP builds. However, it is unwise to ignore the errors, rather than solving them at source. It's also (more) unwise to hide all errors simply due to having expected errors appearing.
As it's only a Notice, you can work around it by setting your error_reporting() value as below:
//report all errors except notices.
error_reporting(E_ALL & ~E_NOTICE);
I would suggest this is far wiser than turning off error reporting entirely which is not recommended. If you want to stop errors being output to browser (as referenced by Tina) you can use display_errors.
Perhaps you may also need to set
ini_set('error_reporting', 0);
depending on your php ini configuration?
Also make sure you set it before carrying out any of the code.

PHP website does not work, and nothing logged in the error log

I have a problem with PHP. There is an error that I have never encountered before. The home.php, which is the main page of my site, cannot be viewed. And there is nothing in error log. After there is an inclusion of a php page (a class that is a part of my API). Till that line the holl HTML (javascript and css inclusions) are echoed from php and successfully rendered in browser, but after the php kind of stops suddenly. When I delete that line(php page inclusion line), website works, but before, this inclusion didn't make any problem for me. I removed the code parts which after them I encountered this problem, but nothing works.
I am using Apache2, PHP5 with Ubuntu 11.10.
Any help will be appreciated, thanks in advance.
My first hints would be to check the following:
In your script set ini_set('display_errors', '1'); and error_reporting(E_ALL); to display all errors.
Turn on the php error log and check it for errors.
run php -l home.php on the command line to check your php file for syntax errors.
Check Apache's error log, sometimes error messages go there.
If nothing helps use a debbugger like XDebug to see where the script terminates, or alternative insert statements like die("here"); and move them around in your code, to see which parts of your scripts are passed.
Greetings and good luck.

Errors in PHP project when shifted from IIS to Apache server

I developed a php project in WebMatrix on IIS. In this project I accidently initialed same "session variable" twice.
Example: File - a.php
<?php
$_Session['one'];
include 'b.php';
...........
...........
...........
...........
?>
Example: File - b.php
<?php
$_Session['one'];
...........
...........
...........
...........
?>
When I run this project from Webmatrix(IIS server) this error wasn't shown but when I ran this project on Apache this error was displayed and I corrected my flaws.
Warning on Apache:
Notice: A session had already been started - ignoring session_start() in D:/path/.
My question is that why this error was not shown earlier? Is it something related to IIS server or WebMatrix. I always need to be aware of the errors or warnings in the code so that I can get rid of them and the efficiency of the code is sustained, please do suggest me some ideal php develeopment tools which can catch even minor errors in my code.
Ensure errors are being displayed and then try turning error_reporting all the way up at the beginning of the application.
ini_set('display_errors', 1);
error_reporting(E_ALL);
Also, be aware that Windows is not case-sensitive. You could say include 'A.php' or include 'a.php' and it would not care. However, when you put it on a Linux-based server, which is case-sensitive, it may not be able to find the file A.php if its actually a.php.
It's possible you got errors because the first server was running PHP 4 and the second is PHP 5. Double-including a file containing functions will get different results in those versions. See the text just before example 6 in this link: http://php.net/manual/en/function.include.php
EDIT: I believe the error messages generated in your edited post indicate something of a different nature.
For files that you want to make sure they are only included one time, use include_once(). http://www.php.net/manual/en/function.include-once.php
There are some situations where you may legitimately want to include() twice from a file. But because those situations are rare, it's best to use include_once().
Warning on Apache:
Notice: A session had already been started - ignoring session_start() in D:/path/.
You can't start session again which is already started.
You need 1 session start at a.php when you include b.php it can use started session.
Its a warning and warning means its not good but php can fix this error and continue working.
Its all about error reporting level.
It is hard to tell if the error didn't occured on IIS or not. Only because it was not displayed or logged, does not mean it didn't occur. Please compare the error reporting php.ini configuration between both systems.
Another thing you should compare in configuration is if session auto-start had been enabled on the old or new system or not. This might be triggering your error, but it's only a guess. As written the error might have been already on the old system but just was unnoticed.

Specific php question

I am fairly new to creating websites and I have done a website that I did in a sandbox server on my personal computer, it works brilliantly, but as soon as I try to put it on my companies server to go up on the internet it doesn't work anymore. What the site does is it takes fields from an html form and then does a sql search of a database that I set up and works fine. Then after the user is done with the form they hit submit and the sql is run and results are returned to the same page. The form action="" and then the results are returned. I am not sure if the companies server has php installed, but I don't know if that would be a problem or not because the browser should still be able to display the php code. I have no problems with the html form, it is just when I hit submit that the page is returned and nothing is displayed.
Any help is welcome.
"I am not sure if the companies server has php installed, but I don't know if that would be a problem"
It is. Browsers can do nothing with PHP. Maybe you shoud register for a free hosting provider and learn the basics of hosting there.
PHP is a server-side language (i.e., it runs on the server, not the user's machine). Therefore, it must be installed on the company's server for any PHP code to execute properly. Browsers cannot interpret PHP code, and moreover PHP code is executed before the browser even receives any information (PHP: Hypertext Pre-Processor). Check that the server has PHP installed before you continue. (Also be aware of versions and features. For example, to use many new PHP features your server must be running PHP5.)
If you find that PHP is installed: Check your PHP syntax; make sure that no headers are sent after text is sent to the page; and make sure that there are no loops or anything in your code that could cause the script to continuously run without printing to the page.
Also, since your page is returned when you hit 'Submit,' but no new information is shown, make sure that there is not a problem with the MySQL configuration (e.g., incorrect password, query syntax, etc).
First you have to be sure that server has PHP installed.
make a file named phpinfo.php with this line
<?php phpinfo() ?>
and call it.
If it won't print out PHP config, you have to install PHP first.
Otherwise the problem most likely in the form of PHP tags, and you are using <? instead of <?php.
To solve, you can either change tags or set short_open_tag to on in the php.ini
According to your comment
when I hit submit that the page is returned and nothing is displayed
I am going to make an assumption that you are getting a blank page. If that is correct, then I am also going to follow that up with the assumption that PHP is installed, there is an error in your script (my guess is the database connection), and that the error is not being displayed.
Add these lines to the top of your page and post back with the result:
error_reporting(E_ALL);
ini_set('display_errors', '1');
Ya I think there is a problem in your database connection.First run your connect file whether it is showing some error or not.Plase add this line to your page:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
And please modify your php.ini file with this line:
display_errors = on

Xampp. Php script displays a blank page!

The php script is calling four functions that scrape different websites for data.
$returnData[0]=getWebsite1Data($description);
$returnData[1]=getWebsite2Data($description);
$returnData[2]=getWebsite3Data($description);
$returnData[3]=getWebsite4Data($description);
The script displays the web-page correctly if I disable the call to any one random function.
That makes me think its a resource problem. If it is a resource problem how do I correct it in Xampp. I've tried unsetting the variables but that didn't work either.
Make sure Error Reporting is set high enough in php.ini
Check your phpinfo and see what your "memory_limit" is. Try doubling it in your php.ini.

Categories