winmastergames Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
Barand Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
unsider Posted February 26, 2008 Share Posted February 26, 2008 Post an error? Have you tested the code? Link to comment Share on other sites More sharing options...
EchoFool Posted February 26, 2008 Share Posted February 26, 2008 mysql_connect("localhost", "root", "com12345") I hope that aint your real password? Your insert query doesn't say what fields to INSERT to for the values either Link to comment Share on other sites More sharing options...
jedney Posted February 26, 2008 Share Posted February 26, 2008 Add this line right below your initial PHP Opening tag: ini_set('error_reporting',E_ALL); I've learned today that this code helps alot. Link to comment Share on other sites More sharing options...
unsider Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
Barand Posted February 26, 2008 Share Posted February 26, 2008 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 Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 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 More sharing options...
EchoFool Posted February 26, 2008 Share Posted February 26, 2008 To be fair though juding by the email of this guy on his/her profile im going to assume the person is under the age of 10 ... so lets not jump at his/her throat too much just yet Link to comment Share on other sites More sharing options...
Barand Posted February 26, 2008 Share Posted February 26, 2008 Closing the topic as it appears to be a double-post. @Winmaster games - DON'T double post in the forums Link to comment Share on other sites More sharing options...
Recommended Posts