View Full Version : need help please...

12-08-2008, 11:10 PM
hey guys im going nuts with this script!!lol

i have a script that pulls images from a database for the client to chose witch one he wants.

now i have a radio button next to the image in a form.that part is cool..the only thing is the script that gets the image name and inserts in the DB that does not get the image name..here is the script
select the image

<? $dbh = mysql_connect("localhost","_","tr") or die("There was a problem with the database connection.");
$dbs = mysql_select_db("techker_gymgraph", $dbh) or die("There was a problem selecting the categories.");


$sql = "SELECT *
FROM `gymball`
WHERE `type` = '$type' ";

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<form action="add_pic1.php" method="post">
<p align="center"><u>Sélectionner UNE photo</u></p>
<table width="346" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><? while($row = mysql_fetch_array($fileLIST)) { ?>
<td width="173"><?php echo '<a href="/Gymgraph/Gymgraph/gymball/'. $row['name'] .'" target="_blank">
<img src="/Gymgraph/Gymgraph/gymball/'. $row['name'] .'" border="0" alt="" width=115/>
<br />'; ?></td>
<td width="173"><label>
<input type="checkbox" name="pic" id="pic" value='<? $row['name'] ?>'/></label>
Selection de photo </label>
<input type="hidden" name="name" id="name" value='<? echo $row['name'] ?>'/>
<input type="hidden" name="ex" id="ex" value='gymball'/>

<? } ?>
<div align="center">
<select name="location" id="location">
<option value="pic1">1</option>
<option value="pic2">2</option>
<option value="pic3">3</option>
<option value="pic4">4</option>
<option value="pic5">5</option>
<option value="pic6">6</option>
<option value="pic7">7</option>
<option value="pic8">8</option>
Emplacement de la photo


<div align="center">
<input type="submit" name="submit" id="submit" value="Submit" />
<div align="center">
<p>Envoyer la sélection </p>
<p><img src="pics/gymgraph_loc.jpg" width="629" height="383" /> </p>

now the add pic



mysql_connect("localhost", "", "tr") or die(mysql_error()) ;
mysql_select_db("techker_gymgraphpics") or die(mysql_error()) ;

//Writes the information to the database
mysql_query("INSERT INTO $location (exercice,name) ".
"VALUES ('$exercice','$name')");

//Tells you if its all ok
$id= mysql_insert_id();
echo "<p>This file has the following Database ID: <b>$id</b>";
echo "You'll be redirected to Home Page after (4) Seconds";
echo "<meta http-equiv=Refresh content=4;url=type.php>";


the part i dont grab is the one were the add_pic1.php grabs the radio button selection and inserts the name of the pic i selected...

12-09-2008, 12:50 PM
Which radio button were you referring to? I don't see any in your code

12-09-2008, 04:07 PM
1. You need to actually add the pic variable to your insert statement.

2. Why do you have the line $pic = $_POST['pic'][0] instead of $pic = $_POST['pic']?