Lassie Posted December 23, 2006 Share Posted December 23, 2006 I am trying to make a folder identified by a hash code.When using the following I get a folder with the variable name and not the variable value.What am I doing wrong?Help please.This is the code<?php/* include ('book_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); //set the variables $email = $POST['email']; */ //create unique hash (email plus salt) and store in database.Values hard coded for testing. $email= '[email protected]'; $salt="nigel"; $hash=md5($email.$salt); include("misc.inc"); $connection = mysql_connect($host,$user,$password) or die ("$connection:".mysql_error($connection)); $db = mysql_select_db($database,$connection) or die ("$db:".mysql_error($connection)); $query = "Insert Into Customer (hash) Values ('$hash')"; $result = mysql_query($query); if (!$result) return false; //create temp folder with hash info //check if folder already exits if(file_exists($hash)) { echo "Dir exist";}else{ mkdir('$hash'); echo "dir made";} exit(); ?> Link to comment https://forums.phpfreaks.com/topic/31701-mk-dir/ Share on other sites More sharing options...
utexas_pjm Posted December 23, 2006 Share Posted December 23, 2006 When you use single quotes here:[code]mkdir('$hash');[/code]It evaluates the string literally i.e., $hash instead of the conents of $hash. Remove the quotes and you should be set.[code]mkdir($hash);[/code]Best,Patrick Link to comment https://forums.phpfreaks.com/topic/31701-mk-dir/#findComment-146935 Share on other sites More sharing options...
Lassie Posted December 23, 2006 Author Share Posted December 23, 2006 Many Thanks Patrick, that worked. On to the next... Link to comment https://forums.phpfreaks.com/topic/31701-mk-dir/#findComment-146949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.