1

okay guys, I've got a problem. I always get the following error line:

Parse error: syntax error, unexpected 'mysql_select_db' (T_STRING) in line 10

here's the whole code:

<html>
<head>
<title>test3</title>
</head>
<body>
<?php
$verbindung = mysql_connect("localhost, test3")
or die ("Fehler")

mysql_select_db("test3");
or die ("Verbindung nicht möglich..."); 

$datum = $_POST["datum"]; 
$autor = $_POST["autor"];
$newstext = $_POST["newstext"]; 

if($datum == "" or $autor == "" or $newstext == "") {
echo "FAIL"
} else {

$eintrag = "INSERT INTO test3
(datum, autor, newstext)

VALUES 
('$datum', '$autor', '$newstext')";

}

mysql_close($verbindung); 
?>
</body>                              
</html>
DarkYagami
  • 93
  • 7

2 Answers2

1
$verbindung = mysql_connect("localhost, test3")
or die ("Fehler"); << semicolon missing

You should add one here as well:

echo "FAIL"; << here

And you have one too much in another place:

mysql_select_db("test3"); << remove here
or die ("Verbindung nicht möglich...");

You will not get your programs to work without some accuracy.

Please also note that mysql extension is deprecated and will not be supported in PHP versions after PHP 5.5 (look at mysqli and PDO extensions), and that your code is prone to SQL Injection.

Community
  • 1
  • 1
syck
  • 2,984
  • 1
  • 13
  • 23
1

Totally u have missed 2 semicolons and added 1 extra semicolon

<html>
<head>
<title>test3</title>
</head>
<body>
<?php
$verbindung = mysql_connect("localhost, test3")
or die ("Fehler");    //----- semicolon here

mysql_select_db("test3")   //  remove semicolon here
or die ("Verbindung nicht möglich..."); 

$datum = $_POST["datum"]; 
$autor = $_POST["autor"];
$newstext = $_POST["newstext"]; 

if($datum == "" or $autor == "" or $newstext == "") {
echo "FAIL" ; //----- semicolon here
} else {

$eintrag = "INSERT INTO test3
(datum, autor, newstext)

VALUES 
('$datum', '$autor', '$newstext')";

}

mysql_close($verbindung); 
?>
</body>                              
</html>
Niranjan N Raju
  • 12,047
  • 4
  • 22
  • 41