Page 1 of 1

No sign

Posted: Tue Aug 02, 2005 2:26 am
by pppswing
Hello,
Me again, so I put Post variable and I try to make it work but each time I get a blank html file, I put different die() everywhere to see where it is but I can't see anything at all. Something is wrong but I can't see it. I wonder if I can split the string for the query as I did.

Thanx.

Code: Select all

<form method="post" action="docu_script.php">
<b>Titre :</b> <input type="text" size="50" name="Titre">
<br /><br />
<b>Auteur :</b> <input type="text" size="50" name="Auteur">
<br /><br />
<b>Nombre de Page :</b> <input type="text" size="4" name="Page">
<br /><br />
<b>Annee d'Edition : <input type="text" size="4"name="Edition">
<br /><br />
<b>Editeur :</b> <input type="text" size="50" name="Editeur">
<br /><br />
<b>Langue :</b> <input type="text" size="50" name="Langue">
<br /><br />
<b>Classification 1er niveau :</b> 
<select name="Class1">
<option value="Informatique">Informatique</option>
<option value="Commerce">Commerce</option>
<option value="Divers">Divers</option>
</select>
<br /><br />
<b>Classification 2nd niveau :</b> <input type="text" size="30" name="Class2">
<br /><br />
<b>Description :</b><br /> 
<textarea name="Description" rows="5" cols="50"></textarea>
<br /><br />
<input type="submit" name="submit" value="Entree">
<br /><br />
<input type="reset" name="RAZ" value="RAZ">
<br /><br />
</form>

Code: Select all

<?php

$link=mysql_connect("localhost","root") or 
	die("could not connect to MySQL");


mysql_select_db("Document") or 
	die("could not connect to Document");
	
$submit = $_POST['submit'];

if( $submit == "Entree")
{
	 $query = "insert into T_Document 
	 (Titre, Auteur, Nombre_Page, Annee_Edition, Editeur,
	 Classification_1, Classification_2, Description) values
	 ($_POST['Titre'], $_POST['Auteur'], $_POST['Page'], 
	 $_POST['Edition'], $_POST['Editeur'],
	 $_POST['Class1'], $_POST['Class2'],$_POST['Description'])";
	 
	 mysql_query($query) or die(mysql_error());
	 mysql_close($link);
?>

<h2>Donnees Entrees</h2>	 
<a href="index.php">retour</a>

<?php
}	else{
   die("Voila");

}
	
?>

Posted: Tue Aug 02, 2005 2:50 am
by shiznatix
you just get a blank page, like it does not say anything at all? try doing print_r($_POST); and see if that turns up anything. is that the entire code for both pages or is there other stuff around?

ps. are you really in tallinn, estonia? if so what part :D

Posted: Tue Aug 02, 2005 3:52 am
by pppswing
Always blank.

Is there free syntax checker and editor for Php you can advise me ?

I'm moving everywhere in Tallinn : Kopli, Kesklinn, Kadriorg, Nomme, Mustamae, Kristiine, Lasnamae.
Now, writing from Kopli Ettevotlusinkubaator.

Posted: Tue Aug 02, 2005 4:23 am
by s.dot
a blank page is most likely a syntax error. Read the contents of your error log.

Posted: Tue Aug 02, 2005 4:33 am
by shiznatix
put error_reporting(E_ALL); at the top, it might be because i think mysql_select_db requires 2 parameters - db name and the $link.

__
awesome, if you are ever around õisma or just want to go to one of the bars in old town give me a PM, i will gladly help you out in person on whatever code since its a lot easier

Posted: Tue Aug 02, 2005 4:54 am
by s.dot
When I'm scripting, even with error reporting set to e_all, I get blank pages when I have a syntax error. I have to check the error log on the server to find out what I did wrong.

Posted: Tue Aug 02, 2005 5:01 am
by shiznatix
that does not make too much sence to me, explain a situation when it would not say like parse error blah blah or whatnot

Posted: Tue Aug 02, 2005 5:27 am
by CoderGoblin
Itend to place

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
in all my code when developing (removing them at a later date).

Another problem for you is is the SQL itself, echo out the SQL you try to run. You can then try that directly via MySQL Admin. My initial impression is you are missing single quotes...

Code: Select all

$query = &quot;insert into T_Document
    (Titre, Auteur, Nombre_Page, Annee_Edition, Editeur,
    Classification_1, Classification_2, Description) values
    ('{$_POST['Titre']}', '{$_POST['Auteur']}', '{$_POST['Page']}',
    '{$_POST['Edition']}', '{$_POST['Editeur']}',
    '{$_POST['Class1']}', '{$_POST['Class2']}','{$_POST['Description']}')
The quotes are only required for text strings. Squiggly brackets just tell the php parser that the contents are a variable.

Be aware that as you perform no validation the form is open to SQL injection attacks.

Posted: Tue Aug 02, 2005 5:42 pm
by timvw
I like CoderGoblins code... The only thing you need to to is perform a [url]http://www.mysql_real_escape_string[/url] on the data in $_POST...

I usually use (i think it's easier to remember ;))
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

But i prefer to have a single std.init.php and include that in each page (safes me from editting all files when i move them into production..)

Posted: Wed Aug 03, 2005 12:02 pm
by pppswing
Thanx to everybody,

CoderGoblin was right about the string mistake and I could see that by allowing error display for web in my php.ini and puting the 2 lines ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
or otherwise, puting error_reporting alone didn't work well.

I don't know where to find my error log on my disk, I'm using Windoz with php 5.

Anyway, thank you very much.

Posted: Wed Aug 03, 2005 12:10 pm
by timvw
Have a look at your php.ini file, around line 240
error_reporting = E_ALL
display_errors = On
log_errors = On
error_log = 'c:/phperrors.log'
Or you could use error_log=syslog and use the eventlogger