0

I'm trying to create a SQL query with a PHP variable, which is a username. For some reason, nothing happens when it is executed. Any help would be much appreciated!

mysqli_query($dbcon, "ALTER TABLE ipList");
mysqli_query($dbcon, "ADD ".$userName." VARCHAR(30)");

Thanks!

~Carpetfizz

1
  • 3
    it should be in a single line, ALTER TABLE ipList ADD ".$userName." VARCHAR(30) Commented Sep 27, 2013 at 20:22

2 Answers 2

7

That's one command. Put it all in one call to query:

mysqli_query( $dbcon, "ALTER TABLE ipList ADD ".$userName." VARCHAR(30)" );
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much! I will accept your answer as soon as it lets me.
I've updated the answer and changed it to mysqli but feel free to change it as your liking :)
1

Your query should look like:

mysqli_query($dbcon, "ALTER TABLE ipList ADD ".$userName." VARCHAR(30)");

But, it seems to me that your database structure is not entirely true.

Do you want each user to create a separate column?

1 Comment

Yeah, I'm essentially trying to accomplish what a graph db does in a relational database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.