Link to home
Start Free TrialLog in
Avatar of Ryan Bayne
Ryan BayneFlag for United Kingdom of Great Britain and Northern Ireland

asked on

The name "test" is not permitted in this context. Valid expressions are constants

Warning: mssql_query() [function.mssql-query]: message: The name "test" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted. (severity 15) in C:\AppServ\www\Test\InsertSQL\process.php on line 20


What exactly does this error mean?
I'm trying to do a very basic INSERT to my datbase!

thanks
<?php
  session_start();
  
  $user="##";
  $host="##\SQLEXPRESS";
  $password="#####";
  $database="##";
 
  
      $connection = mssql_connect($host,$user,$password)  
                or die ("Couldn't connect to server.");
      $db = mssql_select_db($database, $connection)
                or die ("Couldn't select database.");
 
        $today = date("Y-m-d");                          #143
        $sql = "INSERT INTO messages (mestxt,sender,
                  receiver,sentdate) VALUES
                ('$mestxt','$sender',$receiver,
                 '$today')";
        mssql_query($sql);                               #150
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of adathelad
adathelad
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan Bayne

ASKER

Perfect cant beleive I couldnt see that I'm not going to sit closer to my monitor I need to find those things myself! lol

I've fixed it and everything INSERTS apart from my textarea data. Here is my form I'm submitting the data on. Everything appears in the database apart from the message!

Any ideas?
<form method="POST" action="process.php">
	<label>Sending Username
		<input type="text" name="sender" value="<?php echo @$sender ?>" size="20" maxlength="20"/>
	</label>
	<p>
	<label>Receiving Username
		<input type="text" name="receiver" value="<?php echo @$receiver ?>" size="20" maxlength="20"/>
	</label>
	</p>
	<p>
	<label>Message
		<textarea name="textarea" cols="30" rows="5" value="<?php echo @$message ?>"></textarea>
	</label>
	</p>
	 <input type="submit" value="Send Mail">
</form>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I thought it was just the variable $message that mattered but you were right it was the name and now that form works a treat thanks