Page 1 of 1

What is wrong with this code?

Posted: Sat Mar 14, 2009 5:23 pm
by MicroBoy
what is wrong with this code, it tells me:

Code: Select all

Parse error: parse error in C:\xampp\htdocs\elektro\lajm.php on line 38
Line 38 is the line with red color

Code: Select all

<html>
<body>
<?php
include ("menu/menu.php");
?>
</br>
<strong><center><form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Emri: <input type="text" name="emri" /></br>
Lajmi: <textarea name="lajmi" rows="5" cols="26"></textarea></br>
Data: <input type="date" name="data" /></br>
<input type="submit" name="dergo" value="Dërgo" />
</form></center></strong>
 
<?php
if (isset($_POST['dergo'])) {
 
include ("konfig.php");
 
$con = mysql_connect("$serveri","$username","$fjalekalimi");
if (!$con)
  {
  die('Nuk Mund Të Konektohet: ' . mysql_error());
  }
 
mysql_select_db("$databaza", $con);
 
$sql="INSERT INTO lajmet (emri, lajmi, data)
VALUES
('$_POST[emri]','$_POST[lajmi]','$_POST[data]')";
 
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "U Shtua Një Lajm";
 
mysql_close($con)
[color=#FF0000]}[/color]
?>
 
<?php
include ("posht.php");
?>
</body>
</html>

Re: What is wrong with this code?

Posted: Sat Mar 14, 2009 5:25 pm
by php_east
mysql_close($con); ( did i overdo it ? )

Re: What is wrong with this code?

Posted: Sat Mar 14, 2009 5:38 pm
by MicroBoy
Thanks a lot for this fast reply :lol: . Is there any way to do that when I will click the submit button the form would not appear just the message that a news has been added:

Code: Select all

echo "U Shtua Një Lajm";
do you understand?

Re: What is wrong with this code?

Posted: Sat Mar 14, 2009 5:58 pm
by php_east

Code: Select all

 
:
:
:
<?php
include ("menu/menu.php");
if (empty($_POST['dergo'])) 
{
?>
</br>
<strong><center><form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Emri: <input type="text" name="emri" /></br>
Lajmi: <textarea name="lajmi" rows="5" cols="26"></textarea></br>
Data: <input type="date" name="data" /></br>
<input type="submit" name="dergo" value="Dërgo" />
</form></center></strong>
 
<?php
}
 
 
if (isset($_POST['dergo'])) {
 
include ("konfig.php");
 
:
:
:
 

Re: What is wrong with this code?

Posted: Sat Mar 14, 2009 6:50 pm
by MicroBoy
Thanks again, you helped me so much.

Re: What is wrong with this code?

Posted: Sun Mar 15, 2009 10:40 am
by php_east
alright, happy coding. :D