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"
}
}
I cant make my upload image work
Moderators: egami, macek, gesf
-
- php-forum Super User
- Posts: 197
- Joined: Wed Jun 15, 2016 8:35 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.
Next, I notice a missing ; at the end of some lines.
-
- php-forum Super User
- Posts: 197
- Joined: Wed Jun 15, 2016 8:35 am
Also, the quotes are wrong :
Code: Select all
$sql = "INSERT INTO images (image,text) VALUES ('$image',''$text')";
You are going wrong Bro. Image Upload is Easy You can Try AJAX Image Upload Without Refresh or You can also Try simple Image Upload. It will help You Lot. Because I am every time using that You can also try it out.
Thanks
Thanks