No errors coming up!!!!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

No errors coming up!!!!

Post by 2bran »

Hi guys,

I'm relativley new to coding php but it would help if the errors were displayed to outline whats wrong with my script. I'm trying to query a database through a php script from a html form. Everything is set up correctly but there is no updating on the database and the php script returns nothing but a white page.

I did some reading on the net and in the php.ini file all the configuration setting are correct.

If any one has any answers that would be great

yours

William
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

so error_reporting is set to E_ALL and display_errors is set to ON ?

Post your code please.
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

Post by 2bran »

this is the php file being called by the html form

I left the connection and and database info out becasue i don't want to display it on the forum.

Code: Select all

<?PHP 

$PartNo= $_POSTї'PartNo'];
$Mancode= $_POSTї'Mancode'];
$Suppcode= $_POSTї'Suppcode'];
$Descrip= $_POSTї'Descrip'];
$BinNo= $_POSTї'BinNo'];
$Depot= $_POSTї'Depot'];
$Total= $_POSTї'Total'];
$Cprice= $_POSTї'Cprice'];
$Rprice= $_POSTї'Rprice'];

$ Connection= mysql_connect("", "", "");
mysql_select_db ('');

$result = mysql_query
("INSERT INTO parts values ('$PartNo', '$Mancode', '$Suppcode', '$Descrip', '$BinNo', '$Depot', '$Total', '$Cprice', '$Rprice',)");

echo '<h1>You have created the following Part</h1>'
echo 'PartNo'. $PartNo'<br>';
echo 'Description'. $Mancode.'<br>';
echo 'BinNo'. $BinNo.'<br>';
echo 'Total'. $Total.'<br>';
echo 'Retail Price'. $Rprice.'<br>';

echo '<h3><b>The information has now been entered</p></b><br>';
echo '<a href="Createpart.htm">RETURN</a>' . '<a href="Adminhomepage.php">Admin Options</a>';


mysql_close($Connection);

?>

feyd | please use

Code: Select all

tags while the

Code: Select all

tags are offline[/color]
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

Post by 2bran »

thats whats in the php.ini fiel as well

Code: Select all

/**
 * Sets the php error reporting - Please do not change this line!
 */
if (!isset($old_error_reporting)) {
    error_reporting(E_ALL);
    @ini_set('display_errors', '1');
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

typical database debugging:

Code: Select all

$result = mysql_query($query) or die(mysql_error());
place some other die() or echo calls in various places to make sure the code gets there. You may need to use flush() or better yet, command line to make sure the data does get out.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

See that stray comma at the end of the query? It cannot be there.

Was

Code: Select all

$result = mysql_query
("INSERT INTO parts values ('$PartNo', '$Mancode', '$Suppcode', '$Descrip', '$BinNo', '$Depot', '$Total', '$Cprice', '$Rprice',)");
Change to

Code: Select all

$result = mysql_query
("INSERT INTO parts values ('$PartNo', '$Mancode', '$Suppcode', '$Descrip', '$BinNo', '$Depot', '$Total', '$Cprice', '$Rprice')");
BTW - Follow feyd's example and add debugging to your script, this error would have been obvious with it.
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

also change

Code: Select all

echo 'PartNo'. $PartNo'<br>';
to

Code: Select all

echo 'PartNo'. $PartNo . '<br>';
you forgot the last .
Last edited by thegreatone2176 on Sat Mar 05, 2005 12:05 am, edited 1 time in total.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Code tags please. You made a valid point but let's keep source easy to read...
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

Unfortuantly still not working

Post by 2bran »

Unfortuantly its still not working guys, when i submit the form no error messages are appearing nor nothiing is happening to the database. All that is showing is a white blank screen and none of echo statements are apperaing either. Could it be anything to do with 'NULL' fields in the data base. They're all set to null.

any answers please contact back. the last two replies were awesome advice.

cheers.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Two points.

1. It is a bad idea to write INSERT statements without specifying the field names too. Without the field names you must enter every field in the same order that they appear in the database and that includes any fields that have default values like an autoincrement field or timestamp. So double check that every column is in your INSERT query.

The other reason it is a bad idea to leave out field names is that this query and every other INSERT into this table will fail if you add more fields to the table because it will have no idea what to do with undefined fields in your INSERT.

2. You have to add the or die(mysql_error()) to the query statement, if it were there you would have gotten some kind of error message that you could be using to solve this problem.
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

after $result echo it out so you can see exactly what the query is doing alot of times you will just have a value wrong or a variable wont be reading right and mess up the whole thing
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

cool advice

Post by 2bran »

Cheers for the advice guys but unfortauntly nothing is still not working i used or die(mysql_error()); query and still only blank screen(no error messages) i think i something its something else. With regards to smpdawg comment how do you insert an auto increment variable into the database. I think in the query you leave it blank like , (''); i'm i right. Also when inserting can u leave fileds blank in the database.

sorry about the tedious questions quite new to this game. lol

yours william
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you make sure to check the error logs of your server when checking for errors?
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

Post by 2bran »

how do u check the error logs in php.ini
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

You may also want to do a View Source in your browser when you get that "blank" screen. I have seen browsers hide the output from PHP if the HTML is malformed or just because they feel like it.
Post Reply