I cant make my upload image work

images php coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
Martind
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Jan 02, 2017 7:21 am

I cant make my upload image work

Post by Martind » Mon Jan 02, 2017 7:24 am

Hey, im doing a php scripted website via sql and i need to make a upload button and i have done so but it tells me unexpected if on line 4
Here is the code and i would appreciate any help!

<?php
$msg =""
//if upload button is pressed//
if (isset($_POST['up'])) {
$target = "images/". basename($_FILES['image']['name']);

//connect to database
$db=mysqli_connect("localhost","root","","photos");

//get all the sumbitted data from the form
$image = $_FILES['image']['name'];
$text = $_POST['text'];

$sql = "INSERT INTO images (image,text) VALUES ('$image',''$text')";
mysqli_query($db,$sql)//lagre vores data i databasen

//bevæg dataene
if(move_uploaded_file)($FILES['tmp_name']['name'],$target)){
$msg ="Uploaded!";
}else{
$msg ="Der var et problem"
}
}

AdoptiveSolution
New php-forum User
New php-forum User
Posts: 139
Joined: Wed Jun 15, 2016 8:35 am

Re: I cant make my upload image work

Post by AdoptiveSolution » Mon Jan 02, 2017 7:53 am

Please use the code button if you paste code. It's easier to read.

Next, I notice a missing ; at the end of some lines.

AdoptiveSolution
New php-forum User
New php-forum User
Posts: 139
Joined: Wed Jun 15, 2016 8:35 am

Re: I cant make my upload image work

Post by AdoptiveSolution » Mon Jan 02, 2017 7:55 am

Also, the quotes are wrong :

Code: Select all

$sql = "INSERT INTO images (image,text) VALUES ('$image',''$text')";

Martind
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Jan 02, 2017 7:21 am

Re: I cant make my upload image work

Post by Martind » Mon Jan 02, 2017 9:53 am

you cant possible imagine how emberrased i am right now sorry for wasting your time

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest