Error: <?php echo variable in string
Posted: 05 Feb 2017, 12:12
I`m buissy with an simple upload script, every member have a own folder for pictures on my server.
Now i try to add a echo variable but getting a error:
I have a part of my script in code
is their an different variable for: <?php echo $users[email];?>
- or how can i make it work into $upload_dir ?
Now i try to add a echo variable but getting a error:
Code: Select all
Warning: move_uploaded_file(/images/<?php echo $users[email];?>/689886.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\Comments\addnew.php on line 67
Code: Select all
<?php
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
?>
<?php
include('connection.php');
$id = (int) $_GET['id'];
$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>
<?php echo $users['email'];?>
<?php
error_reporting( ~E_NOTICE ); // avoid notice
require_once 'dbconfig.php';
if(isset($_POST['btnsave']))
{
$username = $_POST['user_name'];// user name
$userjob = $_POST['user_job'];// user email
$imgFile = $_FILES['user_image']['name'];
$tmp_dir = $_FILES['user_image']['tmp_name'];
$imgSize = $_FILES['user_image']['size'];
if(empty($username)){
$errMSG = "Please Enter Username.";
}
else if(empty($userjob)){
$errMSG = "Please Enter Your Job Work.";
}
else if(empty($imgFile)){
$errMSG = "Please Select Image File.";
}
else
{
$upload_dir = '/images/<?php echo $users[email];?>/'; // upload directory
$imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
- or how can i make it work into $upload_dir ?