Jump to content

HELP! Passing variables into an INSERT query


Robski

Recommended Posts

This code works fine on my computers' server but when I copy it over to my web space it doesn't:

$name = 'Random';
$password = 'passRandom';

$query = "INSERT INTO Names (name,password) VALUES ('$name','$password')";

mysql_query($query) or die ('Error, insert query failed');

- I can get it to pass strings into the database...just not variables.
- I've emailed my web hosting people and they said I can use the syntax:

$query = "INSERT INTO Names (name,password) VALUES (' ".$name." '.' ".$password." ' )"

But this doen't work either.

Any Ideas?
Link to comment
Share on other sites

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.