What is wrong with this code?

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
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

What is wrong with this code?

Post 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>
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: What is wrong with this code?

Post by php_east »

mysql_close($con); ( did i overdo it ? )
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: What is wrong with this code?

Post 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?
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: What is wrong with this code?

Post 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");
 
:
:
:
 
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: What is wrong with this code?

Post by MicroBoy »

Thanks again, you helped me so much.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: What is wrong with this code?

Post by php_east »

alright, happy coding. :D
Post Reply