Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Error Checking


I have a classic problem: things run properly on my test server but don't
work on the live server (different PHP version, different master Apache
config, etc...) which I do not admin. In particular, for 'security reason'
the access to the error.log file has long been disabled and I don't get any
message on screen. Things just don't happen the way they should.

I've tried putting various takes on this in my .htaccess to no avail:
php_flag display_errors on
php_value error_log /home/dargaud/logs/error.log # Nothing there
php_value error_reporting E_ALL
php_flag html_errors on
php_flag log_errors on
php_flag track_errors on

What else can I try to troubleshoot issues without admin rights on the
server ?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Error Checking Script
I have built this error checking script but it doesn't work PHP Code:

Error Checking On Date
I am writing a script that checks a date that was submitted from the previous form. In cold fusion where is a function called Isdate(variable) and if it came back false, then you kick out an error. I found the checkdate function, but you have to break the date into a Day Month and Year variables. Is there another way to check the date that I'm just not seeing?

Group Error Checking
Need to check a group of form inputs and want to run them in a group instead of separate statements. This is what i have so far and no luck any suggestions. I just put the form fields as variables in these to test and this is a far as I got before I realized this may not be the best way. Any suggestions? Code:

Validation & Error Checking Broken?
I'm validating a simple form for input via post ($PHP_SELF). Near the
end I check for username and password. I'm using simple if, elseif, else
statements.

I require them to enter password twice and check that they match. Problem is
script doesn't valide past username input and I dont know why!! If you don't
enter a password it doesn't do the validation anymore, it just dies for some
reason. I would greatly appreciate anyones help, I've stared at this thing
for hours and hours.

Here is code...

Form Input Error Checking
Have a form field being inserted, needs to only allow an integer value through. Which function do I want to use to check the passed var to see if there are any non-integer values present? PHP Code:

Error Checking Custom Forms
I am writing software that allows users to create custom html forms...when they place the forms on their pages using a display function the site visitor can fill them out. The info is passed to a processing page...it all works dandy if there are no errors.

My question is, if there ARE errors what would be the best wasy to redirect the user back to the form..with the POST data in there. I have looked through the posts regarding headers and fsockopen and stuff like that....but I am not sure how to implement this.

I can grab the $_SERVER['HTTP_REFERER'] from the form page....so I can send them back to the correct page. But I am unclear on the most efficient way to repopulate the form with the information they have submitted...in other words...how can I pass the data back to the form after realizing it had errors.

Even After Proper Error Checking, I Still Get PHP Warnings
I've this class method, which makes sure I've got a variable that is a
resource:

function close() {
if (is_resource($this->datastoreResultsPointer)) {
mysql_free_result($this->datastoreResultsPointer);
mysql_close();
}
}

all the same, I'm getting these PHP errors:

Warning: mysql_free_result(): 286 is not a valid MySQL result resource
in
/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/McDatastoreResultsMySql.php
on line 89

Warning: mysql_close(): no MySQL-Link resource supplied in
/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/McDatastoreResultsMySql.php
on line 90

Error Checking For Unique Value In Database Table?
I am inserting data into user table which contains 5 fields, sounds simple
enough normally but 2 of the fields are designated as UNIQUE. If someone
does enter a value which already exists, how do I capture this specific
error?

Would it make more sense to actually run a SELECT query first and if that
returned a result, then I use that for error checking and don't run insert
until select returns nothing?

Do Professional PHP Programmers Use Error Checking In Their Code?
I've made it habit to check all returns in my code, and usually, on
most projects, I'll have an error function that reports error messages
to some central location. I recently worked on a project where someone
suggested to me I was spending too much time writing error messages,
and that I was therefore missing the benefit of using a scripting
language. The idea, apparently, is that the PHP interpreter writes all
the error messages that are needed, and that I shouldn't write such
code myself. I was given the impression that if I needed extensive
error checking, or strict typing, then I should use a real language,
like Java, but if I'm going to use a scripting language like PHP or
Ruby, then I should leave errors to the interpreter, since the whole
point of using scripting languages is speed of development. Has anyone
else heard this argument, and do you agree with it? I'm wondering how
other PHP programmers handle error messages. Check everything or leave
it to the PHP interpreter to tell you when there is an error?

Which of these two functions is better, the one with error checking or
the one without?

function getWeblogEntries() {
$query = "SELECT * FROM weblogs";
$result = mysql_query($query);
$howManyWeblogEntries = mysql_num_rows($result);
for ($i=0; $i < $howManyWeblogEntries; $i++) {
$row = getRow($result);
extract($row);
echo "<h1>$headline</h1>";
echo "<h7>$date</h7>";
echo "<div class="mainContent">$mainContent</div>";
}
}

function getWeblogEntries() {
$query = "SELECT * FROM weblogs";
$result = mysql_query($query);
if ($result) {
$howManyWeblogEntries = mysql_num_rows($result);
for ($i=0; $i < $howManyWeblogEntries; $i++) {
$row = getRow($result);
if (is_array($row)) {
extract($row);
echo "<h1>$headline</h1>";
echo "<h7>$date</h7>";
echo "<div class="mainContent">$mainContent</div>";
} else {
reportError("In getWeblogEntries, the function getRow
failed to return an array on the $i iteration.");
}
}
} else {
reportError("In getWeblogEntries, the query to the database
failed.");
}
}

Error Checking/code Comparison Tools
does anyone have a cool/free/cheap tool that they use for error-checking that would allow you to e.g. copy code from two different pages and find where they are different?

I have some code that seems to work in one page but not in another and I can't find the difference. I could just copy and paste but then I wouldn't really learn anything.

Problems With Error Checking / Control Of POST Variables
I have a small form that on button press submits to a PHP file for further
processing into a database. I have to change the script as it allows
blank / nothing to be submitted to the database. The intention is that if
any of the two form fields are blank (empty) then the page is resent
stating that they have to fill in all the fields to post (to a database).

If I deliberately leave the fields blank and submit the form, querying the
database shows that both fields are zero / null - so nothing was entered in
to the database.

However, if I use an echo command to see what is going on (before the data
is entered into a database) I get the $TheName field with a "1" and the
$TheComment field with an unknown entry (it doesn't echo anything to the
screen - but it's not empty).

The code I've used to test this is:

$TheName = $_POST[gbName];
$TheComment = $_POST[gbComment];

if (($TheName = NULL) or ($TheComment = NULL))
{
echo 'Quick error check running:<BR>'
echo "Name: $TheName<BR>";
echo "Comment: $TheComment";
exit;
}

This does NOT execute as these fields are not empty. It only runs if I
change to:

if (($TheName = !NULL) or ($TheComment = !NULL))

Which is pointless as it will always execute with genuine entries.

Using the amended code below:

if (($TheName = !NULL) or ($TheComment = !NULL))
{
echo 'Quick error check running:<BR>'
}

echo "Name: $TheName<BR>";
echo "Comment: $TheComment";

I get the result that both the echoed lines are displayed as blank (no
"1").

PHP & CURL Installation Error (checking For Curl_easy_perform In-lcurl)
I'm trying to install the latest PHP4 version from the scratch. The
configure string is following:
../configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
--with-curl --enable-exif --enable-mbsting=all --with-gd --with-openssl
--with-zlib-dir=/usr --with-zlib

Everything goes well until the cURL should be configured. At that point,
I will encounter an error like this:

checking for CURL support... yes
checking for CURL in default path... found in /usr
checking for cURL 7.9.8 or greater... libcurl 7.12.1
checking for curl_easy_perform in -lcurl... no
configure: error: There is something wrong. Please check config.log for
more information.

OK, let's check out the config.log:

[root@finnpower php-4.3.10]# tail config.log
#line 20458 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char curl_easy_perform();

int main() {
curl_easy_perform()
; return 0; }

Following cURL packages are installed:
curl-7.12.1-1
curl-devel-7.12.1-1

In general, I have Fedora Core 3 installed with self-compiled Apache
2... almost with PHP 4.3.10 too.



Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding

if (HTTP_GET_VARS['b']==1){
print "Yes";
}else{
print "No";
}

when "b" is not passed via
(http://www.mydomain.com?b=1

an error occurs and the "NO" is printed but an error is printed too.

How can I check for the value of "b" so that no error occurs if b is
not passed??

example

http=www.mydomain.com

$myvar=HTTP_GET_VARS['b']

causes an error because
"b" does not exist (ie. its not passed in the URL string.

$myvar maybe evaluated as NULL or Empty but the error is printed in
the page, anyway.

URL Checking?
how do you check if a browser came from a specific URL??

Checking For XSS ?
Does the check below ensure that the files are originating from my server,
i.e. to prevent or detect
any type of XSS ? Or is the HTTP_HOST easily spoofed ?

function test ($refer)
{
if (!stristr($refer, $_SERVER["HTTP_HOST"])) {
die();
} else {
}
}

test ($_SERVER["HTTP_HOST"]);

IP Checking
I have to do this for security measures on a script I am doing: To ensure the authenticity of the HTTP requests you should only accept requests from the following IP addresses: 80.87.132.0/26 (ie .0 -> .63) is there a simple way to do a range of IPs ie
IF $ipaddress == 80.87.132.* If not does anyone have a good function for this?

Checking %'s
Is there a built in function to check if a value is a certain % of a different value?

Like:
If($Value < 10% $value2)

sort of thing ?

Or do i have to work out the 10% first then check against that?

IP Checking
I have a rating system, and its supposed to let people vote only once but right now I can vote 50 times in a row if I want, and I dont know why its letting me vote multiple times, here is my code:

Spell Checking
How can i spell check without including the aspell or pspell libraries ( can't include them because i'm on a virtual host ). I don't mind if its an external service. Spellchecker.net was great, expect now you have to pay for it.

Checking A Field
I've seen a couple of form generation and validation scripts.

Checking Input Of An Url Or Ip?
i do use the following code:

Code:
if ($siteurl == "") {
$badreg = true;
$valid_url = false;
echo "<span class='main'><font color='#C10000'><b>Error:</b></font> Please check your url.<br>
";
} else {
$valid_url = true;
$siteurl = ereg_replace("http://", "", $siteurl);
list($domain, $file) = explode("/", $siteurl, 2);
$siteurl = "http://" . $domain . "/" . $file;
}

Any idea how i could extend the " if ($siteurl == "") { " for checking for valid domain names and ip-addresses?

Checking Mail
Is there any easy and quick way to check if a user got any/new mail with PHP? assuming that the user's mailbox is on the same system and the system is UNIX (Linux,BSD, etc.)

Checking If A Url Works
ok i need to check a url to make sure it works, and if it does, then
i want to print out "online", and if it returns 404 then i want to
print out "offline". how do i check if the url works or not?

Checking Paramters In The Url Bar
<?php
if ((!isset($s)) && (!isset($msg))) {
echo("<table>
....

I want some pictures displayed on the main page if its a new visit, but when they search and the url bar changes its skips displaying them, to save scrolling down all the time.

I tried the above to read the parameters but get an error when they are not set.

Is there something simple like this :

if (url has no parameters) {
echo("...draw front page section")

PHP And CGI Checking Of The Code
im trying to write a php app for my forums so when a user posts a message that has some programming code in it they can click on a link i plan on setting up that has a text box for them to paste the code into and hit a button (well call it submit) after they hit the button then the code is read and the syntax of this code is colorized much like Crimson editor does for its differant sytanx.

programming the checking of the code isnt my problem im having trouble figureing out a way to make it so when they inpute it it gets sent to a php program to be checked and then sent back with the proper color tages..so if they were to enter in the text box:

<?php
// blah blah blah
then soem more crap here
?>

they then hit submit the program checks it and sees the syntax for php so it coloriz's it as php syntax and sends back the text liek this

<?php
// blah blah blah
then some more crap here
?>
Quote:
and the code would looke liek this the [] are () so it doesnt show colors in this part but the code will be with the []
<?(color=blue)php(/color)
(color=green)// blah blah blah(/color)
then some more crap here
?>

and then when they copy and paste it into the forum its then colorized as php syntax, any ideas or a tutorial on how to get a CGI script to call a php file to runs checks would be great.

Password Checking
I enter my user name and password into the db as

"insert into prof (puserid,ppassword,p_fname,p_lname) values ('$puserid',password('$ppassword'),'$p_fname','$p_lname')";

This is entered into the db user with password encrypted. But when I try to login and compare it says invalid password. my query is:

$query = "SELECT pid from prof WHERE puserid ='$userid' and
ppassword=password('$pass')";

So in order to check what it is checking against. I did this
$test = password('$pass');
print "$test";

And it gives me a error saying

Fatal error: Call to undefined function: password() in c:apachehtdocsartprofpermislogin.php on line 52 and $test=password('$pass') is my line 52.

What could I do be doing wrong?

Password Checking
I am having a problem with a script that i am using for a user logging, especially regarding the password comparison. what i am trying to do is search mysql database for usernames from the user inputs. this should then put the results into the variable and then i am comparing the database password to the password the user entered.

if it matches then the user is logged into the system. Here is the code, any comments would make me a v happy man! I have declared all the database variables but i wont include them for obvious reason =) Code:

Credential Checking
I was wondering if you anyone knew of a good credentail checking
script to give me a starting point for some scripts.

Checking For Sessions
I have built a cms which is password protected. Each page uses a session to check for the password, and presents info if the password is registered. This all works fine on my server, but when I put it on the clients server, the session doesn't work. And yes, I have changed all the needed info to correlate with her server.

I think the session isn't working. Is there a way I can check the session functionality of the php engine. Like php.ini or something?

Checking URL Problem!!!
I've been writing a page to check whether a url is alive or dead. But
I keep having problem with my php function. The code below is my php
function and 2 urls to test (one is always alive and one is dead-not
valid).
============== check url function ==========
<?php

//This function return HTTP code.
function check_url($url){

// Break the URL down into its parts.
$url_pieces = parse_url ($url);
$path = ($url_pieces['path']) ? $url_pieces['path'] : "/";
$port = ($url_pieces['port']) ? $url_pieces['port'] : 80;
$host = $url_pieces['host'];

$fp = fsockopen ($host, $port, &$errno, &$errstr, 10);
if (!$fp) {
return "$errstr ($errno)";
} else {
fputs($fp, "HEAD $path HTTP/1.0

");
fputs($fp, "HOST: $host
");
fputs($fp, "CONNECTION: close

");

$data = fgets ($fp,128 );

//echo $data;

fclose ($fp);

$array = explode (" ", $data);
return $array[1]; // Return the HTTP code.
}
}

$url1="http://yahoo.com";
$url2="http://www.kdkdkdkdkdkdkdkdk.com";

$check1 = check_url($url1);

echo $url1." ".$check1."<br>";

$check2 = check_url($url2);
echo $url2." ".$check2;

?>
=============================================

The output that I have looks like 2 lines below:

http://yahoo.com 200
http://www.kdkdkdkdkdkdkdkdk.com 200

where 200 represents that a link is alive. However for the second url,
HTTP code can't be 200 because that url doesn't exist.

I don't know what wrong with my code,

Checking Path.
I have a script that allows the user to open a file in the server and show it, this is so new files can be published without having to modify the script. What I want to check is that the file requested is not outside the path so they can't access other files in the system. let's supose all the files are in: $COMUNET_ROOT/../public_files/ and the file is $page so I wrote this: PHP Code:

Checking For Username...
How do I check in a mySQL table called 'Users' on column user_name when
registering a new user_name to make sure the new 'user_name' does not
already exist in that column?

Checking Other Sessions
I have implemented some login functionality using session variables which is quite straightforward and works well. Except for 1 requirement that I can't work out how to do.
I would like to prevent the same user from logging in more than once. But in order to do this I need to somehow see if that user is logged in already - i.e. check "other" sessions - is that possible?

Variable Checking
Does any one know if theres a way of checking that a variable just contains numbers and no letters or symbols.

Checking Date
if i use date() in php to get date, im getting date that my computer has right? wen i change that date of my computer, the date that i get from the function date() not be accurate. what php function i can use where i can get accurate date.

Checking If Ip's Are Still Up
I need to write a script that goes through a list of ips and see's if those ip's are still in use, or if they're dead. I tried using checkdnsrr but it returned false for every ip. Is there another function I should use? Is there an easy way to do this in Perl?

Checking Database
Is it possible to check the database to see if information being submitted is already present in the database?

Checking A Checkbox
Is it possible to preset the values of form elements with php - so that when
the client gets the page certain boxes are checked or completed - on the
fly - based on their HTML id.

Javascript has a way of doing this - but i need the functionality of PHP
too - so if i can move the whole thing over to php it owuld be better .

javascript example -

document.forms['form1'].elements['radiobuttonno'].checked = true;

Checking If A Site Is Available
What PHP code would I use to check if submitted sites to my directory
actually exist?? I want to use something that can return the server
code to me, ie HTTP 300 OK, or whatever. Can I do this with sockets?

Checking If Gd Has Already Installed
I installed php4.3.2 , apache 2.0.47 and mysql-standard-4.0.14.

1- it seems that they work properly , but i want to know how i can be sure if GD has been installed corrcetly. ??

2- BTW any clue about commands by which i can get the information ( like version ...) of a.m component??

Checking Date
mysql query thur php, would this be correct to see if date submitted was 10 or more minutes ago date_submitted <=(NOW() - 3600)

Checking A Url Exists
I've looked on this newsgroup on google and on php.net, but I can find
a work function which will allow me to check if a url exists?

Checking Date
I have a form where user must enter the year ($year), month ($month) and day ($day). What I want to do then if check and see if this date is in the future. If it's in the past I want to print an error message, if it's in the future then it's ok.

Checking If URL Is Valid
What kind of regular expression pattern is needed to check
if URL is valid? It's enought if most of cases are covered.

I have PHP 4.x.

Checking Passwords
i'm making a php based login system and i need help checking usernames and passwords to see if they're correct.

Checking The $_POST
Is there a way to check if $_POST has any values ?

something like if ($_POST !=' ')

Constant Checking
for the following script, how would i make it display multiple unequipped items but not display the same ones more than once?

//unequipped items -------------------------------------------------------------------
    $uneq="SELECT * from km_items where owner='$player' and status='u'";
    $uneq2=mysql_query($uneq) or die("Could not get user stats");
    $uneq3=mysql_fetch_array($uneq2);
if (!empty ($uneq3[id])) {
echo "<a href=equip.php?itemid=$uneq3[id]><img src='$uneq3[itempic]'";
} else {
}

Query Checking
How do i do a if statement after a query to do something like "if the row does exist.. set value = 1 else set to = 0"

This is my query so far:

Quote$Check = mysql_query("SELECT * FROM Banks WHERE UserID='{$_SESSION['Current_User']}' AND BankID='1'");

Any ideas?

Checking MySQL
How would I write a function that returns true if it finds a matching entry in the table. For example: In table tab, column col, there are multiple different entries but a matching entry may be about to be inserted, how can I check if it's already there?

I also need it to return true or false for the purpose of an if statement. If it is already in the database it should return true.

function check(){
} My code so far, yes pathetic.


Copyright © 2005-08 www.BigResource.com, All rights reserved