Page 1 of 2
No errors coming up!!!!
Posted: Fri Mar 04, 2005 7:12 pm
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
Posted: Fri Mar 04, 2005 8:00 pm
by feyd
so error_reporting is set to E_ALL and display_errors is set to ON ?
Post your code please.
Posted: Fri Mar 04, 2005 8:08 pm
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
Posted: Fri Mar 04, 2005 8:13 pm
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');
}
Posted: Fri Mar 04, 2005 8:39 pm
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.
Posted: Fri Mar 04, 2005 10:18 pm
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.
Posted: Fri Mar 04, 2005 10:56 pm
by thegreatone2176
also change
to
you forgot the last .
Posted: Fri Mar 04, 2005 11:58 pm
by smpdawg
Code tags please. You made a valid point but let's keep source easy to read...
Unfortuantly still not working
Posted: Sat Mar 05, 2005 5:10 am
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.
Posted: Sat Mar 05, 2005 9:22 am
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.
Posted: Sat Mar 05, 2005 10:59 am
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
cool advice
Posted: Sat Mar 05, 2005 11:38 am
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
Posted: Sat Mar 05, 2005 11:41 am
by feyd
did you make sure to check the error logs of your server when checking for errors?
Posted: Sat Mar 05, 2005 1:02 pm
by 2bran
how do u check the error logs in php.ini
Posted: Sat Mar 05, 2005 1:08 pm
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.