Hi there - code first:
<?php
Include("../includes/confstring.php");
Include("../includes/variables.php");
$link = "insertil.php";
Include("../includes/sessions.php");
If (!$_GET['id'])
{
header("location: $siteurl/admin/index.php");
}
else
{
$id = $_GET['id'];
}
$username = $_SESSION['username'];
$rank = $_SESSION['user_rank'];
$link = $_POST['link'];
$name = $_POST['name'];
$img = $_FILES['img'];
//Stripslashes
$newstitle = stripslashes($newstitle);
$newsbody = stripslashes($newsbody);
//Submit to mysql
for ($x=0; $x<count($link); $x++) {
$sql = mysql_query("INSERT INTO links (sectionid,link) values ('" . $id . "','" . $link[$x] . "')")
or die("Could not connect to the database.");
echo $sql;
}
for ($x=0; $x<count($link); $x++) {
$sql = mysql_query("INSERT INTO images (sectionid,name,url) values ('" . $id . "','" . $name[$x] . "','" . $img[$x] . "')")
or die("Could not connecta to the database.");
echo $sql;
}
if ($_FILES['img']['type'] == "image/gif"){
copy ($_FILES['img[$x]']['tmp_name'], "files/".$_FILES['img[$x]']['name'])
or die ("Could not copy");
echo $_FILES['img[$x]'];
}
?>
I've changed some of the code that I recieved from cgraz and various others, trouble is, as I explained to them, I'm fairly new to this type of coding. 😃 So basically what's wrong with it is that first the links don't get added, second the files don't get uploaded and thirdly the file url's don't get uploaded.
You can probably see from the code what each bit of code does.. as can I - it's just getting it to work differently that's the problem!
Any ideas?
Help will be greatly appreciated,
Chris