hmm - to questions, firstly I can't tell but have I made a mistake in one of these two scripts?
This script submits the form:
<?php
Include("includes/confstring.php");
Include("includes/variables.php");
$link = "options.php";
Include("includes/sessions.php");
If (!$_GET['id'])
{
header("location: $siteurl/admin/index.php");
}
else
{
$id = $_GET['id'];
}
If (!$_POST['rlinks'] AND $_POST['images'])
{
header("location: $siteurl/admin/index.php");
}
elseif ($_POST['rlinks'] == '0' AND $_POST['images'] == '0')
{
header("location: $siteurl/admin/index.php");
}
If (!$_POST['rlinks'])
{
}
else
{
$lnum = $_POST['rlinks'];
}
If (!$_POST['images'])
{
}
else
{
$imgnum = $_POST['images'];
}
Include("templates/header.php");
Include("templates/fateam.css");
?>
<table width="620" align="right">
<tr>
<td class="main">
<form name="addparts" action="<? echo $siteurl ?>/admin/templates/insertil.php?id=<? echo $id ?>" method="post">
Please add your related links and upload your images here.<br \n><br \n>
<?
echo 'Related links: <br \n>';
for($num=1; $num<=$lnum; $num++)
{ echo 'Link: <input type="text" name="link[$num]" id="link[$num]"><br \n>';
}
echo '<br \n> Images: <br \n>';
for($fnum=1; $fnum<=$imgnum; $fnum++)
{ echo 'Image: <input type="file" name="img[$fnum]" id="img[$fnum]"><br \n>';
}
?>
<br \n><input type="submit" name="submit" value="Submit"><input type="reset" name="reset" value="Reset">
</form>
</td>
</tr>
</table>
<?
Include("templates/footer.php");
?>
and this bit is the bit with the for statement.
<?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'];
$image = $_POST['images'];
//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;
}
?>
My echo $sql only show's '1' so I've done something wrong I presume.
Also, why do you use the . $id . instead of just '$id'?
Thanks,
Chris