473,472 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please use error_reporting(E_ALL)

Just a couple of quick comments:

In some of the CSS/DOM mailing lists I'm on, people generally
refuse to help unless the HTML and CSS will validate. You
can check these at http://validator.w3.org/check/ and
http://jigsaw.w3.org/css-validator/check/ respectively, and it will
often sort out problems you are experiencing with layout/display if
your code validates properly.

This has led me to think of things that could be done in here, to reduce
the number of "easily fixed" posts. A lot of the problems that people in
this newsgroup tend to experience would have been easier to solve
if they did these things:

- put error_reporting(E_ALL); in all your code. If you have a globally
included/required file, stick it in the start there. Most of your
problems will become easier to identify.

You will probably find that you get problems with
Notice: undefined index in ....
Fix these by doing
if (array_key_exists('myvar', $_POST))
{
// do stuff with $_POST['myvar']
}
etc

- turn register_globals OFF. Use $_POST['variablename'] rather than
$variablename for form data. Similarly use $_GET, $_FILES, $_SERVER, $_SESSION, etc.
Your code will work on more servers, with less work, and you'll have a better handle
on where the data is coming from. Probably better to avoid $HTTP_POST_VARS if you
have a sufficiently current version of PHP; if you don't, better to use
$HTTP_POST_VARS['myvar'] than $myvar

- Check the value of mysql_error() if queries fail:
if (!($result = mysql_query($sql, $connection)))
{
print "Couldn't execute the query\n<pre>$sql</pre>\nMySQL error is \n".mysql_error();
}

- If you need to make a function call that could result in an error, you can always prefix
it with @ :
if (!@move_uploaded_file($somefile, $someotherfile))
{
// clean up here
}

- Check your query result has data in it, before fetching arrays/rows from it:
either do
if (mysql_num_rows($result))
{
// do stuff
}

or

while ($row = mysql_fetch_assoc($result))
{
// do stuff
}

- If necessary, make sure you use addslashes(0 on data before putting it into an SQL query

- Escape entities in HTML code (htmlentities(), urlencode() for URL query strings, etc)

- If your form post/file upload handlers aren't working, try doing
var_dump($_POST) or var_dump($_FILES) to see what input you're getting

Also, if you get a strange or incomprehensible error message, it's often quite
productive to try searching for the "standard" part of it in google, enclosed in quotes,
e.g. http://www.google.com/search?q=%22un...sql_connect%22

Anyone else think of any more?

I'm not trying to be nasty; it's just that following some basic checks will allow
you to find your errors more quickly and easily, and you'll start writing more
robust code as a result!

Matt
Jul 16 '05 #1
6 2465
matty:
Just a couple of quick comments:

In some of the CSS/DOM mailing lists I'm on, people generally
refuse to help unless the HTML and CSS will validate. You
can check these at http://validator.w3.org/check/ and
http://jigsaw.w3.org/css-validator/check/ respectively, and it will
often sort out problems you are experiencing with layout/display if
your code validates properly.

This has led me to think of things that could be done in here, to reduce
the number of "easily fixed" posts. A lot of the problems that people in
this newsgroup tend to experience would have been easier to solve
if they did these things:


You're probably right, problem is they don't come here until they experience
the problem, and they clearly haven't got the slighest clue about how to
use Google Groups.

But as long as someone's willing to help I guess it's ok, but I've simply
stopped answering most of these simple questions.

André Nęss
Jul 16 '05 #2
André Nęss wrote:


You're probably right, problem is they don't come here until they
experience the problem, and they clearly haven't got the slighest clue
about how to use Google Groups.

But as long as someone's willing to help I guess it's ok, but I've simply
stopped answering most of these simple questions.

André Nęss


Maybe we need a FAQ...
Jul 16 '05 #3
matty:
Maybe we need a FAQ...


We certainly do, and the topic has been discussed before, but someone simply
has to do it :/ A Wiki is maybe an even better idea as it makes it simple
for many people to cooperatively develop it.

André Nęss
Jul 16 '05 #4
Agelmar wrote:
matty wrote:
André Nęss wrote:


You're probably right, problem is they don't come here until they
experience the problem, and they clearly haven't got the slighest
clue about how to use Google Groups.

But as long as someone's willing to help I guess it's ok, but I've
simply stopped answering most of these simple questions.

André Nęss


Maybe we need a FAQ...


Matty, it's the same problem. People who are asking FAQ-type questions
(e.g. register_globals questions, mysql insert / update questions, etc.)
typically do not read the group before posting and/or look for the answer
anywhere else.


Well, I'll put my site back up in a week or two - if anyone has any other
suggestions for a FAQ, stick em in here (or email them to me) and I'll put
them in!

Jul 16 '05 #5
André Nęss wrote:
matty:
Maybe we need a FAQ...


We certainly do, and the topic has been discussed before, but someone
simply has to do it :/ A Wiki is maybe an even better idea as it makes it
simple for many people to cooperatively develop it.

André Nęss

Don't know if I'd be prepared to do a Wiki - too many wiki terrorists around.
Maybe something with a confirmed email registration - I'll have a think. In
general, what would people want to see, beyond standard faq/wiki stuff?
Jul 16 '05 #6
Hi Matty!
On Mon, 11 Aug 2003 01:33:57 +0000, matty
<ma*******@askmenoquestions.co.uk> wrote:
André Nęss wrote:
matty:
Maybe we need a FAQ...


We certainly do, and the topic has been discussed before, but someone
simply has to do it :/ A Wiki is maybe an even better idea as it makes it
simple for many people to cooperatively develop it.

André Nęss

Don't know if I'd be prepared to do a Wiki - too many wiki terrorists around.
Maybe something with a confirmed email registration - I'll have a think. In
general, what would people want to see, beyond standard faq/wiki stuff?


I think a FAQ would be more than enough. The FAQ of de.comp.lang.php.*
is fabolous and contains not much more than FAQ.

Jochen

--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tim Tyler | last post by:
I've been experimenting with using: error_reporting (E_ALL); However, lines like this report problems when the variable is missing: $open = $_GET; Is there some way to do that with error...
1
by: Pedro Fonseca | last post by:
Greetings everyone! I'm porting my applications to PHP5 and I've stumbled on yet another problem. I'll try to simplify things a bit. I have a main script that is being executed (index.php, PHP5...
9
by: comp.lang.php | last post by:
I am having problems tracing errors in my code using PHP 4.3.9 on Linux RHEL 4 with Apache 2.0.54 On occasions I see no errors, no parse, no fatal, no warnings, no notices.. and no code either!...
5
by: comp.lang.php | last post by:
I have a PHP script that has only one line: <?php error_reporting(E_ALL & ~E_NOTICE); ?> When run as CLI PHP I get an extremely large number of warnings, errors and notices, all related to the...
12
by: cpptutor2000 | last post by:
I am new to PHP and I am having a very odd problem. Could some PHP guru please help. I am passing some variables from one page to the next, and in the starting page, I have: <div...
2
by: mrbog | last post by:
Here's my code: <?php error_reporting(E_ALL); ini_set("display_startup_errors","1"); ini_set("display_errors","1"); wefw wefwef=wefwe
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.