Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    42
    Thanks
    4
    Thanked 0 Times in 0 Posts

    need help please...

    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
    PHP Code:
    <? $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.");

    $type=$_POST['type'];


    $sql "SELECT * 
    FROM `gymball` 
    WHERE `type` = '$type' "
    ;
    $fileLIST=mysql_query($sql);
    $file=$row['name'];
    ?>

    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GymGraph</title>
    </head>

    <body>

    <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/>
    </a> 
    <br />'
    ?></td>
    <td width="173"><label>
    <input type="checkbox" name="pic" id="pic" value='<? $row['name'?>'/></label>
    Selection de photo </label>
    <label>
    <input type="hidden" name="name" id="name" value='<? echo $row['name'?>'/>
    <input type="hidden" name="ex" id="ex" value='gymball'/>
    </label></td>

    <? ?>
    </table>
    <p>
    <p>
    <label>
    <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>
    </select> 
    Emplacement de la photo

    </label>

    <label>
    <div align="center">
    <input type="submit" name="submit" id="submit" value="Submit" />
    </div>
    </label>
    <div align="center"> 
    <p>Envoyer la sélection </p>
    <p><img src="pics/gymgraph_loc.jpg" width="629" height="383" /> </p>
    </div>
    </p>
    </form>
    </body>
    </html>
    now the add pic
    PHP Code:
    <?php

    $pic
    =$_POST['pic'][0]; 
    $location=$_POST['location'];
    $name=$_POST['name'];
    $exercice=$_POST['ex'];


    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
    $idmysql_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...

  • #2
    Regular Coder lokeshshettyk's Avatar
    Join Date
    Aug 2008
    Location
    On the way to the moon!
    Posts
    157
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Which radio button were you referring to? I don't see any in your code

  • #3
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    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']?

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •