Jump to content


Photo

where is the problem ..mysql or php


  • Please log in to reply
13 replies to this topic

#1 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 25 May 2003 - 07:31 PM

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
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#2 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 26 May 2003 - 07:08 AM

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.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#3 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 26 May 2003 - 11:14 AM

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
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#4 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 26 May 2003 - 12:36 PM

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.
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#5 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 26 May 2003 - 01:10 PM

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

anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#6 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 26 May 2003 - 01:22 PM

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)

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#7 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 26 May 2003 - 07:18 PM

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

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

any one a idea?
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#8 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 27 May 2003 - 07:03 AM

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.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#9 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 27 May 2003 - 04:45 PM

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

could be something wrong with mysql??

i am running 3.23.44 as mysql
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#10 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 27 May 2003 - 05:52 PM

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
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#11 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 28 May 2003 - 08:26 AM

What is the output of the code I wrote?

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

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#12 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 28 May 2003 - 10:26 AM

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

#13 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 May 2003 - 12:51 PM

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
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner

#14 vaan

vaan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 03 June 2003 - 12:25 PM

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.
anyone how find\'s this topic usefull. PLEASE click the banner. Else phpfreaks is a gonner




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users