Jump to content

Recommended Posts

SQL statement failed with error: 37000: [Microsoft] [ODBC SQL Server Driver] [sql Server] The name 'jackjack' in this context is not allowed. 
Only constants, expressions with Bridge and variables are permissible. Column names are not permissible .

 

here is the code that i have created to try and add user details to the database:

 

<?php

$con = odbc_connect("xxx","xxxx","xxxx") or die ("cannot find server");


$sql = 'insert into netpeople(
				name,
				email,
				username,
				password
				) 
				VALUES
				(
				"' . $_POST['name'] . '", 
				"' . $_POST['email'] . '",
				"' . $_POST['username'] . '",
				"' . md5($_POST['password']) . '"
				)';


$results = odbc_exec($con, $sql);
if (!$results) {
    print("SQL statement failed with error:\n");
    print(odbc_error($con).": ".odbc_errormsg($con)."\n");
  } else {
    print("One data row inserted.\n");
  }  

?>
<form name="registration_form" method="post">
Name:<input type="text" name="name"><br>
E-mail:<input type="text" name="email"><br>
Username:<input type="text" name="username"><br>
Password:<input type="password" name="password"><br>
Repeat password:<input type="password" name="password_confirmation">
<input type="submit" value="Register">
</form>

Link to comment
https://forums.phpfreaks.com/topic/198262-what-does-this-error-message-mean/
Share on other sites

You are using double-quotes around the values, which causes them to be treated as identifiers (i.e. column, table, or database names.)

 

You need to switch the use of quotes. Use double-quotes at the start and end of the php strings and use single-quotes inside the sql syntax.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.