Windows 7 User - Odd PHP Script error - anyone help please?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Windows 7 User - Odd PHP Script error - anyone help please?
[text]
Notice: Undefined index: itemtype in C:\xampp\phpMyAdmin\justbbguns\index.php on line 6
Notice: Undefined index: sort in C:\xampp\phpMyAdmin\justbbguns\index.php on line 13
[/text]
Hello
I am one of many people who now use Windows 7, and XAMP.
I now have this problem when running a web site locally. All databases are installed, and even some results are showing, but i get many of these errors. One was about acookie, and line 6 is to do with a session.
Hope someone can shed a bit of light on it.
Simon
Notice: Undefined index: itemtype in C:\xampp\phpMyAdmin\justbbguns\index.php on line 6
Notice: Undefined index: sort in C:\xampp\phpMyAdmin\justbbguns\index.php on line 13
[/text]
Hello
I am one of many people who now use Windows 7, and XAMP.
I now have this problem when running a web site locally. All databases are installed, and even some results are showing, but i get many of these errors. One was about acookie, and line 6 is to do with a session.
Hope someone can shed a bit of light on it.
Simon
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
Previously in php.ini, error_reporting or display_errors was set differently. It is now set to display all errors (even notices). The problem is that the code is attempting to use an array element but it doesn't exist (bad code). The problem was always there you just didn't see it.
You get this error if you do this:
But not if you do this:
You get this error if you do this:
Code: Select all
echo $somearray['itemtype'];Code: Select all
$somearray['itemtype'] = 'something';
echo $somearray['itemtype'];
Last edited by AbraCadaver on Mon Jan 31, 2011 2:22 pm, edited 1 time in total.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
It means you are trying to access a key that doesn't exist in the array.
I.e.,
EDIT | Beaten.
I.e.,
Code: Select all
$myArray = array(
'foo' => 'bar',
'blah' => 'bleh'
);
//generate undefined key notice
echo $myArray['someRandomKeyThatDoesntExist'];-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
Hi.
The thing you pointed out - the $something - my code isn't doing that.
What is the previous version of XAMP then? I'll just uninstall and install that version instead as I cannot be doing with those errors, when the previous one was fine.
That code on all our web sites run without error.
The thing you pointed out - the $something - my code isn't doing that.
What is the previous version of XAMP then? I'll just uninstall and install that version instead as I cannot be doing with those errors, when the previous one was fine.
That code on all our web sites run without error.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
It's not? I thought that was the whole reason you made this thread!simonmlewis wrote:Hi.
The thing you pointed out - the $something - my code isn't doing that.
Wrong. Your code on all your websites are running WITH errors. You are just not displaying them. The best solution would be to fix the culprit, otherwise, simply setThat code on all our web sites run without error.
Code: Select all
error_reporting(0);Code: Select all
ini_set('display_errors', 0);-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
It's not a case of me not displaying the errors - perhaps the servers by the professional hosting companies doesn't show them - but whatever - I DON'T AND HAVE NOT SEEN ERRORS IN 5 YEARS.
Where is that php.ini file as i cannot trace it. Sorry.
Where is that php.ini file as i cannot trace it. Sorry.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
OK we'll you obviously know what your doing if you've never seen an error in 5 years, hmm, or maybe it's because you haven't had error reporting on for 5 years. I just can't figure out which.simonmlewis wrote:It's not a case of me not displaying the errors - perhaps the servers by the professional hosting companies doesn't show them - but whatever - I DON'T AND HAVE NOT SEEN ERRORS IN 5 YEARS.
Where is that php.ini file as i cannot trace it. Sorry.
So let me be clear -- YOU HAVE ERRORS. Yes, it is a case of you just not displaying them. Just because your server configuration is setup to not display them, doesn't mean they aren't being generated. You want proof? Go check your php error log. It's probably crammed full of notice/error messages.
Anyways, my advise is to enable it during dev and disable it on live servers. So I probably wouldn't enable it now, especially since you know YOU HAVE ERRORS (whether you admit it or not
Talk to your host, if you are on shared hosting, you likely do not have access to it. I've already described how to enable it via code. You can also enable these with .htaccess.
I'm out of here now. Good luck.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
Ok.Well all I know is that I haven't seen any errors ever, and my hosts clearly have it switched off as default.
I cannot find that error reporting in php.ini.
It's all very well pointing out that I have errors, but I have dozens of web sites all coded the same, and no errors have come up, and my hosts have never informed me of any. So I've never been told how to show myself these apparent errors/
But I need to knw how to switch it off. Even tho you have said it's in php.ini, I cannot find that when i search. If you mean to enter it in there...WHERE?
I cannot find that error reporting in php.ini.
It's all very well pointing out that I have errors, but I have dozens of web sites all coded the same, and no errors have come up, and my hosts have never informed me of any. So I've never been told how to show myself these apparent errors/
But I need to knw how to switch it off. Even tho you have said it's in php.ini, I cannot find that when i search. If you mean to enter it in there...WHERE?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
internet-solution
- Forum Contributor
- Posts: 220
- Joined: Thu May 27, 2010 6:27 am
- Location: UK
Re: Windows 7 User - Odd PHP Script error - anyone help plea
John has already showed you how to enable it via code in a post above.
Maybe you should give more attention to what others are saying, especially when they are trying to help you?John Cartwright wrote: The best solution would be to fix the culprit, otherwise, simply setorCode: Select all
error_reporting(0);Code: Select all
ini_set('display_errors', 0);
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
Why are developers often so prickly?!
As I said, I don't know where that should be placed. I've never had to do that.
He says it should go in php.ini, but not where, and not if that is already there and just needs changing to that.
I cannot find it.
"Here are some brakepads, they need replacing on that wheel.
Where?
On that wheel - he told you.
Where in that wheel?"
As I said, I don't know where that should be placed. I've never had to do that.
He says it should go in php.ini, but not where, and not if that is already there and just needs changing to that.
I cannot find it.
"Here are some brakepads, they need replacing on that wheel.
Where?
On that wheel - he told you.
Where in that wheel?"
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
Another example of an error:
[text]Notice: Undefined index: head in C:\xampp\phpMyAdmin\site\index.php on line 356
[/text]
Code:
How is this code incorrect?
It's calling part of the URL, and if it isn't NULL, then it does something.
Also, I have spoken with my hosting company who say the errors I showed here are not the sorts of errors they have seen before, particular not that would appear thru the error_reporting.
Is it purely down the 1.7.4 or XAMPP on Windows 7 64 BIT??
[text]Notice: Undefined index: head in C:\xampp\phpMyAdmin\site\index.php on line 356
[/text]
Code:
Code: Select all
$head = $_REQUEST['head'];
if ($head != NULL) { echo "<div class='head'>
$head</div>";}It's calling part of the URL, and if it isn't NULL, then it does something.
Also, I have spoken with my hosting company who say the errors I showed here are not the sorts of errors they have seen before, particular not that would appear thru the error_reporting.
Is it purely down the 1.7.4 or XAMPP on Windows 7 64 BIT??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
You have to remember, we volunteer our time to help others. We can't hold your hand through the entire process. People who do that for you earn a paycheck.simonmlewis wrote:Why are developers often so prickly?!
As I said, I don't know where that should be placed. I've never had to do that.
He says it should go in php.ini, but not where, and not if that is already there and just needs changing to that.
I cannot find it.
"Here are some brakepads, they need replacing on that wheel.
Where?
On that wheel - he told you.
Where in that wheel?"
Moving on.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
The code is incorrect because you are attempting to use a variable that does not exist. The proper way to do that would be to check that the variable exists before using it. I.e.,simonmlewis wrote:Another example of an error:
[text]Notice: Undefined index: head in C:\xampp\phpMyAdmin\site\index.php on line 356
[/text]
Code:How is this code incorrect?Code: Select all
$head = $_REQUEST['head']; if ($head != NULL) { echo "<div class='head'> $head</div>";}
It's calling part of the URL, and if it isn't NULL, then it does something.
Code: Select all
$head = isset($_REQUEST['head']) ? $_REQUEST['head'] : null;
//long form
$head = null;
if (isset($_REQUEST['head'])) {
$head = $_REQUEST['head'];
} Then they have no idea what they are talking about. These are exactly the errors you'll generally find in error logs (especially poor written applications).Also, I have spoken with my hosting company who say the errors I showed here are not the sorts of errors they have seen before, particular not that would appear thru the error_reporting.
It is purely down on your code. The Apache configuration just happened to be different on this setup.Is it purely down the 1.7.4 or XAMPP on Windows 7 64 BIT??
Like I mentioned, if your on a shared host you likely do not have access to your php.ini. Therefore, your best option would be to ask your host to disable it, if you're unwilling to fix your code. Otherwise, include that code to disable error reporting at the top of your scripts. Note, fatal errors will still show because the code will not be able to run if it cannot be parsed, thus never disabling error reporting.
I don't know how to explain it any more than that. Just talk to your host, they are there to serve you.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
The problem has now bee resolved using another method - far simpler than changing hundreds of lines of code.
The query I posted about $head = $_REQUEST['head'];, and then asking if it is not NULL.... why is that wrong?
Surely that variable is dead unless it is called, and it is only called in my code when asked if there is anything it in.
Version 1.7.3 from what I understand is a far better version anyway. I've read nothing but bad things about it, from someone saying the developer of that 1.7.4 should be shot, to you name it.
So I think I'll stick with 1.7.3 anyway. Works fine. And I have never turned off any error reporting, so maybe 1.7.4 is a lot stricter, and based on views of many, is rubbish anyway.
I also asked my host about error logs on their server, and they said if there were, and if they were mounting up (we have loads of web sites), then they would soon be telling me. Nothing reported tho.
Interesting reading.
And some of us DO need a little extra help. It's 'data', not 'information', when you tell someone they need something in a file, but don't tell there where, especially when they have no idea.
The query I posted about $head = $_REQUEST['head'];, and then asking if it is not NULL.... why is that wrong?
Surely that variable is dead unless it is called, and it is only called in my code when asked if there is anything it in.
Version 1.7.3 from what I understand is a far better version anyway. I've read nothing but bad things about it, from someone saying the developer of that 1.7.4 should be shot, to you name it.
So I think I'll stick with 1.7.3 anyway. Works fine. And I have never turned off any error reporting, so maybe 1.7.4 is a lot stricter, and based on views of many, is rubbish anyway.
I also asked my host about error logs on their server, and they said if there were, and if they were mounting up (we have loads of web sites), then they would soon be telling me. Nothing reported tho.
Interesting reading.
And some of us DO need a little extra help. It's 'data', not 'information', when you tell someone they need something in a file, but don't tell there where, especially when they have no idea.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Windows 7 User - Odd PHP Script error - anyone help plea
The reason PHP is so popular because it lets you write bad code. When PHP internally generates notices/errors that should be enough for any programmer to realize they are doing something wrong. I'm not going to debate whether this is bad practice.. because it's a horrible practice.simonmlewis wrote:The problem has now bee resolved using another method - far simpler than changing hundreds of lines of code.
The query I posted about $head = $_REQUEST['head'];, and then asking if it is not NULL.... why is that wrong?
Surely that variable is dead unless it is called, and it is only called in my code when asked if there is anything it in.
I assume your talking about xampp. I haven't used a pre-packaged server software in a long time, so I'll take your word for it. Server configurations vary from installation to installation, so it was just chance your history of error reporting settings. Like I mentioned earlier, you should always have error reporting disabled in a live environment. Although memory serves that xampp installs came with error reporting enabled by default because it's primarily used in a local environment (not on live servers).Version 1.7.3 from what I understand is a far better version anyway. I've read nothing but bad things about it, from someone saying the developer of that 1.7.4 should be shot, to you name it.
So I think I'll stick with 1.7.3 anyway. Works fine. And I have never turned off any error reporting, so maybe 1.7.4 is a lot stricter, and based on views of many, is rubbish anyway.
If I were you, I would just ask them to give you the error log. Take a look at it and I'm sure you'll be surprised on how often your errors are going unnoticed.I also asked my host about error logs on their server, and they said if there were, and if they were mounting up (we have loads of web sites), then they would soon be telling me. Nothing reported tho.
If I knew where your php.ini file was located, I would have told you. It varies from OS, Server, and installer... which was why I told you to speak to your hostInteresting reading.
And some of us DO need a little extra help. It's 'data', not 'information', when you tell someone they need something in a file, but don't tell there where, especially when they have no idea.
Anyhow.. glad you got things resolved.