FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » I need Help
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: I need Help [message #169688 is a reply to message #169686] Wed, 22 September 2010 20:46 Go to previous messageGo to previous message
Robert Hairgrove is currently offline  Robert Hairgrove
Messages: 19
Registered: September 2010
Karma:
Junior Member
Patrick Ehrmann wrote:
> Hi,
>
> I have a problem with the script below! Unfortunately I can not find
> the error! The connection to the server works and also to the
> database. But no values are written into the table!
> Can you help me?
>
> Thank you
>
> PE
>

You could use mysql_error() after checking the return value of
mysql_query() to find out why...


> **************************************************
> <?php
>
> /*****************************
> *verbindung mit der Datenbank*
> *****************************/
>
> $verbindung = mysql_connect("localhost","******","******") or die
> ("keine Verbindung möglich. Benutzernahme und Kennwort sind Falsch");
> mysql_select_db("usr_web216_1") or die ("DB nicht gefunden");
>
>
> /****************************
> *** Einlesen Formular********
> *****************************/
> $dojoid = $_POST['dojonr'];
> $pruefungs_ort = $_POST['port'];
> $datum = $_POST['pdatum'];
>
> $name = $_POST['name'];
> $vorname = $_POST['vorname'];
> $alter = $_POST['alter'];
>
> $seilchenspringen = $_POST['seil'];
> $dreiersprung = $_POST['dreisprung'];
> $knieliegestütz = $_POST['knieliege'];
^
I'm not sure, but I think it's not allowed to use anything but ASCII
characters in PHP variable names. However, I may be wrong.

> $rückenmuskel = $_POST['ruekenm'];
> $stand_h_sprung = $_POST['stand_h_sprung'];
> $medizinball_ws = $_POST['medizin'];
> $japanlauf = $_POST['japanlauf'];
> $crunch = $_POST['crunch'];
> $laufdis = $_POST['laufdis'];
> $laufzeit = $_POST['laudzeit'];
>

Here it would be very wise to check the user input for malicious code
(Google for "SQL injection"...)

>
> /***************************
> ***Eintrag in die Tabelle***
> ****************************/
>
> $eintrag = "INSERT INTO usr_web216_1, bl_auswertung (id, Dojo_id,
^^^
This should be:
$eintrag = "INSERT INTO usr_web216_1.bl_auswertung (...)

You have a comma and extra space between your schema name and the name
of the table. It should be a period (full stop) instead of a comma, and
no space. And since you already selected the database after connecting,
you don't necessarily need to prefix the table name with the schema name
(although I think it is a good habit to do so).

> Pruefungs_ort, Pruefungs_datum, Name, Vorname, Alter,
> Seilchenspringen, Dreiersprung, Knieliegestuetz, Rueckenmuskeltest,
> Stand_h_sprung, Medizinball_ws, Japanlauf, Crunch, Laufdis, Laufzeit)
> VALUES ('', '$dojoid', '$pruefungs_ort', '$datum', '$name',
> '$vorname', '$alter', '$seilchenspringen', '$dreiersprung',
> '$knieliegestütz', '$rückenmuskel', '$stand_h_sprung',
> '$medizinball_ws', '$japanlauf', '$crunch', '$laufdis', '$laufzeit')";
> /*
> $eintrag = "INSERT INTO `usr_web216_1`,`bl_auswertung` (`id`,
^^^
Same thing...

You really don't need backticks unless you are using reserved words as
identifiers. I don't like them myself; PhpMyAdmin always sticks them on,
but probably because it doesn't really know what names are being used
and can't take chances.

> `Dojo_id`, `Pruefungs_ort`, `Pruefungs_datum`, `Name`, `Vorname`,
> `Alter`, `Seilchenspringen`, `Dreiersprung`, `Knieliegestuetz`,
> `Rueckenmuskeltest`, `Stand_h_sprung`, `Medizinball_ws`, `Japanlauf`,
> `Crunch`, `Laufdis`, `Laufzeit`)
> VALUES
> (\'\', \'$dojoid\', \'$pruefungs_ort\', \'$datum\', \'$name\',
> \'$vorname\', \'$alter\', \'$seilchenspringen\', \'$dreiersprung\',
> \'$knieliegestütz\', \'$rückenmuskel\', \'$stand_h_sprung\',
> \'$medizinball_ws\', \'$japanlauf\', \'$crunch\', \'$laufdis\',
> \'$laufzeit\')";*/
>
>
> $eintragen = mysql_query($eintrag);
> if($eintragen == true)
> {
> echo "Eintrag war Erfolgreich";
> }
> else
> {

Here you should call mysql_error()...

> echo "Fehler beim Speichern";
> }
>
> mysql_close ($verbindung);

PHP takes care of this automatically, I believe.

>
>
> ?>
> <html>
> <head> <title>Leistung</title> <meta http-equiv="refresh" content="1;
> URL=../Leistungen.html"> <meta name="keywords" content="automatic
> redirection"> </head>
> <body> Sie werden umgeleitet.
> <?php if (empty($fehler)) {
> echo "Eintrag erfolgreich";
> } ?>
> </body>
> </html>
>
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Book problems and solution for windows 7
Next Topic: Syntax for array?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 19:21:50 GMT 2024

Total time taken to generate the page: 0.04467 seconds