Jump to content

where is the problem ..mysql or php


vaan

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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");

Link to comment
Share on other sites

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) 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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\')\";

Link to comment
Share on other sites

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.

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.