Jump to content

two questions


mike12255

Recommended Posts

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
Share on other sites

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
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.