vaan Posted May 25, 2003 Share Posted May 25, 2003 hello, I must say i like this board... but i have a problem for days now.. I have made this piece and it just won\'t work.. Can any one tell me what\'s wrong?? Oh and it has more $results in the code.. $sql8 = "INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\');"; $result = mysql_query($sql8) or die("Couldn\'t execute query.1"); tnx Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/ Share on other sites More sharing options...
pallevillesen Posted May 26, 2003 Share Posted May 26, 2003 What is the error ? Try echoing the sql error, fetch it using the following: echo mysql_errno() . \": \" . mysql_error(). \"n\"; and a quick evil note... sql8 or sq18 ? sq one eigth or sq L 8 ? I always use an underscore between alphabetic characters and letters, so you don\'t make mistakes... Hope this helps, P. Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1695 Share on other sites More sharing options...
vaan Posted May 26, 2003 Author Share Posted May 26, 2003 sorry it doesn\'t work.. it just gives a 0 (zero) i don\'t realy know know what that means.. can someone explain?? and by the way is it possible that i insert not variables but just text.. see abouve (admin etc) tnx K Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1696 Share on other sites More sharing options...
shivabharat Posted May 26, 2003 Share Posted May 26, 2003 In this case we can have a clear pic if u can put more of ur code. U havent said what the output u get . is that nothing happend or u get the die statement executed. Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1699 Share on other sites More sharing options...
vaan Posted May 26, 2003 Author Share Posted May 26, 2003 i just get as error print 0 (zero).. here is a little piece of my code, it contains many more but that is setting up the table... i hope you all can help me... include "include/db.php"; $server = "$host"; $mysql_user = "$user"; $mysql_password = "$pass"; $database = "$db"; // Connecting to mysql $link = mysql_connect($server, $mysql_user, $mysql_password) or die("Could not connect to mysql!<br />mysql error: " . mysql_error()); // Selecting databse mysql_select_db ($database, $link) or die("Could not select db!<br />mysql error: " . mysql_error()); print (" <BR><CENTER><BR><BR><BR> <BR><BR><FORM ACTION=setup1.php METHOD=post>Username:<BR> <INPUT TYPE=TEXT NAME=username class=button><BR> <BR>Password:<BR> <INPUT TYPE=password NAME=password class=button><BR><BR> <br>Fullname:<BR> <INPUT TYPE=TEXT NAME=fullname class=button><BR> <br>Email:<BR> <INPUT TYPE=TEXT NAME=email class=button><BR> <INPUT TYPE=SUBMIT VALUE=SUBMIT NAME=sent class=button></FORM><BR><BR><BR>"); $sql_8 = "INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\');"; echo mysql_errno() . ": " . mysql_error(). "n"; print "()"; $result1 = mysql_query($sql8) or die("Couldn\'t execute query.1"); $sql1 = "INSERT INTO settings (adminame, email) VALUES (\'$fullname\', \'$email\');"; $result = mysql_query($sql1) or die("Couldn\'t execute query.2"); Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1705 Share on other sites More sharing options...
shivabharat Posted May 26, 2003 Share Posted May 26, 2003 Try this $sql8 = "INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\');"; echo mysql_errno() . ": " . mysql_error(). "n"; print "()"; $result1 = mysql_query($sql8) Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1706 Share on other sites More sharing options...
vaan Posted May 26, 2003 Author Share Posted May 26, 2003 sorry it still doesn\'t work.... wile other inserts in my script work.. here not anymore :roll: any one a idea? Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1713 Share on other sites More sharing options...
pallevillesen Posted May 27, 2003 Share Posted May 27, 2003 Ok, mysql error number 0 is NO ERROR... and since you call it BEFORE you actually try and do the insert, then it is quite obvious that there is no error YET. So... $sql_8 = "INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\');"; $result1 = mysql_query($sql_8) or die("Couldn\'t execute query.1"); echo "<pre>The statement $sql_8 gave the following: ".mysql_errno() . ": " . mysql_error(). "</pre>"; $sql1 = "INSERT INTO settings (adminame, email) VALUES (\'$fullname\', \'$email\');"; $result = mysql_query($sql1) or die("Couldn\'t execute query.2"); echo "<pre>The statement $sql1 gave the following: ".mysql_errno() . ": " . mysql_error(). "</pre>"; P. Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1721 Share on other sites More sharing options...
vaan Posted May 27, 2003 Author Share Posted May 27, 2003 it still doesn\'t give a error.... could be something wrong with mysql?? i am running 3.23.44 as mysql Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1728 Share on other sites More sharing options...
vaan Posted May 27, 2003 Author Share Posted May 27, 2003 CREATE TABLE `user` ( `ID` int(11) NOT NULL auto_increment, `userid` varchar(100) NOT NULL default \'\', `password` varchar(16) NOT NULL default \'\', `fullname` varchar(100) NOT NULL default \'\', `email` varchar(100) NOT NULL default \'\', `userlevel` varchar(100) default NULL, `webspace` varchar(100) default NULL, this is my table structure Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1731 Share on other sites More sharing options...
pallevillesen Posted May 28, 2003 Share Posted May 28, 2003 What is the output of the code I wrote? I.e. what does the sql_8 and sql1 contain ? P. Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1744 Share on other sites More sharing options...
gizmola Posted May 28, 2003 Share Posted May 28, 2003 Try changing this line: $sql_8 = \"INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\');\"; to: $sql_8 = \"INSERT INTO user (userid, password, fullname, email, userlevel, webspace) VALUES (\'$username\', \'$password\', \'$fullname\', \'$email\', \'admin\', \'0\')\"; Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1749 Share on other sites More sharing options...
vaan Posted May 28, 2003 Author Share Posted May 28, 2003 thnx gizmola at least it inserted admin.. not many but it\'s a start does any one know the solution.. @biopv: it just printed the statments... nothing else Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1750 Share on other sites More sharing options...
vaan Posted June 3, 2003 Author Share Posted June 3, 2003 thanks guys for all the help. I had to rewrite the whole script. I just made it a little bit different. It\'s too long to explain.. But if someone else has the same problem just sent me messages. Quote Link to comment https://forums.phpfreaks.com/topic/505-where-is-the-problem-mysql-or-php/#findComment-1814 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.