Jump to content

Archived

This topic is now archived and is closed to further replies.

vaan

where is the problem ..mysql or php

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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");

Share this post


Link to post
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) 

Share this post


Link to post
Share on other sites

sorry it still doesn\'t work....

 

wile other inserts in my script work.. here not anymore

:roll:

 

any one a idea?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

:cry: it still doesn\'t give a error.... :cry:

 

could be something wrong with mysql??

 

i am running 3.23.44 as mysql

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

What is the output of the code I wrote?

 

I.e. what does the sql_8 and sql1 contain ?

 

P.

Share this post


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

Share this post


Link to post
Share on other sites

thnx gizmola

 

at least it inserted admin.. not many but it\'s a start :D

 

does any one know the solution..

 

@biopv:

 

it just printed the statments... nothing else

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.