Will anyone give me a hand on this code...

A

Anonymous

Guest
Code:
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  <label>
  <p>Welcome Friends</p>
  <p>Guest's Name:   
    <input type="text" name="guestname" size="80">
    </br>
  </p>
  <p>E-mail Address: 
    <input type="text" name="email" size="80">
    </br>
</p>
  <p>Message: </p>
  <p>
    <textarea name="message" rows="20" cols="80"></textarea>    
    </br>
  </p>
  <p>    <input type="submit" name="Send">	
  </p>
</form>
<?php
  $con=@mysql_connect('127.0.0.1','root','') or die ('Cant established any connection'.mysql_error()); 
  
  mysql_select_db('jd') or die ('Unable to resolve database'.mysql_error());
  
  if (isset($_POST['guestname']) && ($_POST['email']) && ($_POST['message']))
  {
    $guestname=$_POST['guestname'];
	$mail=$_POST['email'];
	$message=$_POST['message'];
	
	$sql="INSERT INTO guest set guestid='', guestname='$guestname',postdate=CURDATE(),email='$mail',message='$message'";
	
	if (@mysql_query($sql))
	{
	   echo 'Message Posted';
	 }
	  else
	  {
	    echo 'Unable to resolve database'.mysql_error();
	  }  
  
  $view=@mysql_query("Select * guest");
  
  if(!$view){
  exit('Unable to display records'.mysql_error());
  }
  
  while ($link=mysql_fetch_array($result,MYSQL_ASSOC))
       {
	    echo "<tr>\n"."</br>";
        foreach ($link as $col_value)
        {
          echo "\t\t<td>$col_value</td>\n"."</br>";
        }
         echo "\t</tr>\n";
       }
       echo "</table>\n";

       mysql_free_result($result);
       mysql_close($connectdb);
	    
		echo '<p><a href="' . $_SERVER['PHP_SELF'].'?message=1">Leave me a message</a></p>'; 

?>
</body>

i cant figure out whats wrong with this code... when i execute this.. it returns an error message like this:
Parse error: syntax error, unexpected $end in D:\apachefriends\xampp\htdocs\jade\insert.php on line 75

anybody could help...please guys...

Edited by Alexei Kubarev: added code tags. Please use them next time
 
you are missing a } - from what I can see, it comes from here:

Code:
if (isset($_POST['guestname']) && ($_POST['email']) && ($_POST['message'])) 
{

So at the end of that IF, then insert your } :)

Andrew
 
can u give the script at line 75, it might be the problem,
and may be u should change u'r script at line 45
if(!$view){
exit('Unable to display records'.mysql_error());
into :
if(!$view)
exit('Unable to display records'.mysql_error());
 
line 75 will be either a blank line or not exist in a viewer... unexpected $end simply means that you have missed a } somewhere...

Andrew
 
Thanks a lot bezmond.... i got it now.... may i ask some more questions?


regarding to my link to that code...$_SERVER('PHP_SELF').... it cant access to my database... its FORBIDDEN... why is that so?
 
ice_blizzard said:
Thanks a lot bezmond.... i got it now.... may i ask some more questions?


regarding to my link to that code...$_SERVER('PHP_SELF').... it cant access to my database... its FORBIDDEN... why is that so?
To you need set password to your databes.
What exactly error message you are get?
 
it give me this message....


Forbidden
You don't have permission to access /jade/< on this server.


--------------------------------------------------------------------------------

Apache/2.0.52 (Win32) mod_ssl/2.0.52 OpenSSL/0.9.7d PHP/5.0.2 Server at localhost Port 80
 
ice_blizzard said:
it give me this message....


Forbidden
You don't have permission to access /jade/< on this server.


--------------------------------------------------------------------------------

Apache/2.0.52 (Win32) mod_ssl/2.0.52 OpenSSL/0.9.7d PHP/5.0.2 Server at localhost Port 80
Ouch! I'm really never see this error on the Windows platform. try see file permission your
D:\apachefriends\xampp\htdocs\jade\insert.php or change PHP_SELF directive
 
thanks a lot for the help guys...
Wizard...i already figure it out...there is just something wrong with my code...thats why it cant access to my database..
i already modified it and it works perfectly fine now...

hehehe!!.. guys thanks for the hand..
 
Back
Top