No sign

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pppswing
Forum Commoner
Posts: 33
Joined: Thu Jun 10, 2004 2:04 am
Location: Tallinn, Estonia

No sign

Post 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");

}
	
?>
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
pppswing
Forum Commoner
Posts: 33
Joined: Thu Jun 10, 2004 2:04 am
Location: Tallinn, Estonia

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

a blank page is most likely a syntax error. Read the contents of your error log.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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..)
pppswing
Forum Commoner
Posts: 33
Joined: Thu Jun 10, 2004 2:04 am
Location: Tallinn, Estonia

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
Post Reply