Jump to content

Weird MySQL error


GB_001

Recommended Posts

For some reason, I keep getting a MySQL error with this script.

Please help.

 

<?php
session_start();
$MN=$_SESSION['email'];
$PN=$_SESSION['password'];

@mysql_connect("localhost", "gb_GB", "*********") or die(mysql_error());
@mysql_select_db("gb_USERInfo") or die(mysql_error());

$query="SELECT * FROM Ysers WHERE email = '$MN' AND Friend=0";
mysql_query($query)or die (mysql_error());

mysql_query("CREATE TABLE $MN(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), Friends VARCHAR(255), Pending INT, Relationship VARCHAR(255)")or die(mysql_error());

$query="UPDATE Ysers SET Friend='1' WHERE email='$MN' LIMIT 1";

mysql_query($query) or die(mysql_error());
mysql_close();
?> 

 

Error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@hotmail.com(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), Friends VARCHAR(25' at line 1

Link to comment
Share on other sites

Much easier to do it in one table.

 

CREATE TABLE freinds (
  id INT NOT NULL AUTO_INCREMENT,
  user VARCHAR(80),
  friend VARCHAR(80),
  PRIMARY KEY(id)
);

 

Then, say I had the friends bob, bill and mandy.

 

INSERT INTO friends (user,friend) VALUES ('thorpe','bob');
INSERT INTO friends (user,friend) VALUES ('thorpe','bill');
INSERT INTO friends (user,friend) VALUES ('thorpe','mandy');

 

Now, to find all my friends....

 

SELECT friend FROM friends WHERE user = 'thorpe';

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.