Jump to content

[SOLVED] Unexpected T_STRING


Akenatehm

Recommended Posts

Hey Guys,

 

I am trying to make a script that sends data from a form to a mysql table. It seems like it is connecting to the database fine but then it comes up with the following error:

 

Parse error: syntax error, unexpected T_STRING in /home/kaurlcom/public_html/testform.php on line 39

 

Here is the code:

 

<?php

include "connect.php";

if(isset($_POST['submit']))

{

   $username=$_POST['username'];

   $password=$_POST['password'];
   
   $email=$_POST['email'];

   if(strlen($username)<1)

   {

      print "You did not enter a username.";

   }

   else if(strlen($password)<1)

   {

      print "You did not enter a password.";

   }

   else

   {

      $insert="Insert into users (username,password,email) values('$username','$password','$email')";

      mysql_query($insert) or die("Could not insert comment);
  
     }

  }

?>

Link to comment
https://forums.phpfreaks.com/topic/133845-solved-unexpected-t_string/
Share on other sites

you didnt close your quotations on the die() function on line 37.  Use the code below and try again.

 

<?php

include "connect.php";

if(isset($_POST['submit']))

{

   $username=$_POST['username'];

   $password=$_POST['password'];
   
   $email=$_POST['email'];

   if(strlen($username)<1)

   {

      print "You did not enter a username.";

   }

   else if(strlen($password)<1)

   {

      print "You did not enter a password.";

   }

   else

   {

      $insert="Insert into users (username,password,email) values('$username','$password','$email')";

      mysql_query($insert) or die("Could not insert comment");
     
     }

  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.