Jump to content

Help with my Mysql and Php Script


winmastergames

Recommended Posts

Whats wrong with this anyone know?

<?php 
$swduser = $_GET["user"];
$titleadd = $_POST["titleadd"];
$sloganadd = $_POST["sloganadd"];
// Connects to your Database 
mysql_connect("localhost", "root", "com12345") or die(mysql_error()); mysql_select_db("swd-dbweb") or die(mysql_error()); 
mysql_query("INSERT INTO $user VALUES ( '1', '$titleadd', '$sloganadd')") or die(mysql_error());
Print "Your table has been populated"; 
?>

Thanks very much

 

Link to comment
Share on other sites

I haven't a clue.

 

I don't know the structure of whatever tablename is held in the $user variable so I dont know if that insert query is syntactically correct.

 

I don't know if mysql_error() is giving an error message, and if it is, I have no idea what the message is.

 

You give no indication of what might be going wrong - what is doing that it shouldn't do, or what isn't it doing that it should do.

 

In other words, don't just post code and ask "What's wrong with this?" and expect a solution.

Link to comment
Share on other sites

mysql_query("INSERT INTO $user VALUES ( '1', '$titleadd', '$sloganadd')") or die(mysql_error());

Thank

 

Echo is probably right, there seems like thus could be the problem, wouldn't it be

 

INSERT INTO user //this is the table// VALUES ('.', etc...

Link to comment
Share on other sites

Your insert query doesn't say what fields to INSERT to for the values either

 

You don't have to specify the fields if you provide a value for every field in the correct order. Which is why there's no way of knowing if it's correct without knowing the table structure

And all this guys done is pretty much post the same code twice (on 2 different posts), with no input if we're actually helping him
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.