Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

combining multiple variables for mkdir

Codes here !

Moderators: macek, egami, gesf

combining multiple variables for mkdir

Postby nichodiaz » Wed Aug 29, 2012 8:10 pm

I am creating my users two files when they register. at the bottom of my code you will see. when I changed this code I get this error now.

error in registrationYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

I dont see why this when give me an error at line one where my connect file is but maybe someone can help me out with this..





<?php
include ('connect.php');

/* Now we will store the values submitted by form in variable */
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$username=$_POST['username'];
$email=$_POST['email'];
$web=$_POST['web'];
$password=$_POST['password'];
$password1=$_POST['password1'];


/* Now we will check if username is already in use or not */
$queryusername=mysql_query("SELECT * FROM users WHERE username='$username' ");
$checkusername=mysql_num_rows($queryusername);
if($checkusername != 0)
{ echo "Sorry, ".$username." is already been taken."; }
else {

/* now we will check if password and confirm password matched */
if($password != $password1)
{ echo "Password and confirm password fields were not matched"; }
else {
//making a dir for default avatar image */
$default_image = "members/default/default_avatar.jpg";
//making a dir for the users gallery images to be stored */
$gallery = "gallery";
$directory = "members/$username/$gallery";
/*file mode set for global access */
$mode = "0777";
/* Now we will write a query to insert user details into database */
$insert_users=mysql_query("INSERT INTO users (first, last, phone, mobile, username, email, web, password, profileimage, gallery) VALUES ('$first', '$last', '$phone', '$mobile', '$username', '$email', '$web', '$password', '$default_image', '$directory'");

if($insert_users)

{ //creates a dir for the user
mkdir($directory, $mode, true);
echo "Registration Successful Please Login.<a href='access.php'>Redirecting to login page</a>";
header( "refresh:1;url=access.php" );
}

else
{ echo "error in registration".mysql_error();
header( "refresh:4;url=access.php" );
}

/* closing the if else statements */
}}

mysql_close();
?>
nichodiaz
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sat Aug 25, 2012 10:23 pm

Re: combining multiple variables for mkdir

Postby nichodiaz » Wed Aug 29, 2012 9:02 pm

well for anyone who also needs the answer to this... Here is how I accomplished it.


//making a dir for default avatar image */
$default_image = "members/default/default_avatar.jpg";

//making a dir for the users gallery images to be stored */
$gallery = "gallery";
$directory = "members/$username/$gallery";

/*file mode set for global access */
$mode = "0777";

/* Now we will write a query to insert user details into database */
$insert_users=mysql_query("INSERT INTO users (first, last, phone, mobile, username, email, web, password, profileimage, gallery) VALUES ('$first', '$last', '$phone', '$mobile', '$username', '$email', '$web', '$password', '$default_image', '$directory')");

if($insert_users)

{ //creates a dir for the user
if (!is_dir ($directory))
{
//the third parameter set to true allows the creation of
//nested directories specified in the pathname.
mkdir($directory, $mode, true);
}
nichodiaz
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sat Aug 25, 2012 10:23 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron