mike12255 Posted July 20, 2009 Share Posted July 20, 2009 one there seems to be a problem with my query while entering a username and password into a table Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/schoolw1/public_html/forjosh/step2.php on line 259 <div id="container"> <div id="top"> <?php if ($_POST['submit']){ ?> <h1>Installation Step 2 Of 3</h1> </div> <div id="leftSide"> <?php if (mysql_connect($_POST['db'],$_POST['dbuser'],$_POST['dbpass'])){ if (mysql_select_db($_POST['dbname'])){ $sql1= " CREATE TABLE `schoolw1_admin`.`users` ( `username` VARCHAR( 255 ) NOT NULL , `password` VARCHAR( 255 ) NOT NULL ) ENGINE = MYISAM"; if (mysql_query($sql1)){ echo "Created users table, moving onto inserting user info"; $sql2 = "INSERT INTO users (username,password) VALUES('$_POST['username']','md5($_POST['password']'))"; if (mysql_query($sql2)){ echo "Username and password sucsesfully added!"; } } }else{ echo "<div id=\"rightSide\">Error I could connect to the db but i couldnt select the requested db name</div>"; } }else{ echo "<div id=\"rightSide\">Error connecting to db on the entered IP</div>"; } I know its the way i entered my variables into the query, i just dont know how to fix it :S second, is it possible to use the fwrite function to create a php file for example user fills in a form and i create a file called config.php with that info? Link to comment https://forums.phpfreaks.com/topic/166670-two-questions/ Share on other sites More sharing options...
gijew Posted July 20, 2009 Share Posted July 20, 2009 My eyes hurt but I'll take a stab at this. Take the quotes out of $sql2 and make it something like $sql2 = "INSERT INTO users (username,password) VALUES($_POST['username'],md5($_POST['password']))"; And to answer the second question, that would be yes. Just change the file extension to .php instead of .txt Link to comment https://forums.phpfreaks.com/topic/166670-two-questions/#findComment-878855 Share on other sites More sharing options...
mike12255 Posted July 20, 2009 Author Share Posted July 20, 2009 didnt work, i tried that already, i threw a die ($_post['username']) infront of $sql2 and it skips it and goes right to the error in my sql2 query Link to comment https://forums.phpfreaks.com/topic/166670-two-questions/#findComment-878863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.