Jump to content

elkidogz

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by elkidogz

  1. HMMM yeah that's not really a problem, the output from the form is fine, it's the processing of the insert that i'm having issues with. getting the variables from checkboxes into the database. should have a listing like this person a radio person b radio person c radio ... pic A Checkbox title Value = file1.jpg pic B Checkbox title Value = file2.jpg pic C Checkbox title Value = file3.jpg ... if i select pic B and pic C with radio a radio a relates to pic B, pic C it should be doing an insert for each B and C with person A
  2. the form generates it's values from two tables: persons are generated here: $result = mysql_query("SELECT * FROM persons"); $output="<tr>"; while($row = mysql_fetch_array($result)) { $counter = $counter + 1; $output .="<!-- START ROW FOR Radio " .$row['name']."--> "; $output .=" <td width=10 id=left10 align=left valign=top >".$counter.". "; $output .=" </td>"; $output .=" <td width=120 id=middle align=left valign=top >"; $output .=" <input type=radio name=PERSONS value=".$row['name']." >".$row['name']; $output .=" </td>"; $output .=" <td width=10 id=right10 valign=top ></td>"; $output .="<!-- END ROW FOR Radio " .$row['Name']."--> "; if ( $counter % 1 == 0 ) { $output .= "</tr><tr>"; } } $output .="</tr>"; // open the file $fhandle = fopen( "FormParts/personsBullets.php", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output ); and pictures (the checkboxes) are generated here: $result = mysql_query("SELECT * FROM pictures"); $output="<tr>"; while($row = mysql_fetch_array($result)) { $counter = $counter + 1; $output .="<!--START ROW FOR checkbox " .$row['fileName']." --> "; $output .=" <td width=10 id=left10 align=left ><!--".$counter."--><br></td>"; $output .=" <td width=120 id=middle align=center valign=top >"; $output .=" <a href=".$fileURL."".$row['fileName']." ><img src=".$fileURL."THUMBS/".$row['fileName']." ></a><br>"; $output .=" <input type=checkbox name=PICTURES value=".$row['fileName']." />".$row[picTitle]; $output .=" </td>"; $output .=" <td width=10 id=right10 ><br></td>"; $output .="<!-- END ROW FOR checkbox " .$row['fileName']." -->"; if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; } } $output .="</tr>"; // open the file $fhandle = fopen( "FormParts/pictureCheckBoxes.php", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output ); // close the file fclose( $fhandle ); include('FormParts/pictureCheckBoxes.php'); Form is this simple: <form id="makerelation" action="makerelation.php" method="POST"> <fieldset> <legend>Relate pictures and person</legend> <table id="makerelations" border="0" colspan="0" cellpadding="0" cellspacing="0" align="left"> <tr> <td align="left"> Choose a person </td> <td width="5"><br> </td> <td align="left"> Pick the Pictures that include the person you chose. </td> </tr> <td align="left" valign="top"> <table id="persons" width="140" border="0" colspan="0" cellpadding="0" cellspacing="0" align="left"> <tbody valign="top"> <?php include('makerb4allpeople.php'); ?> </tbody> </table> <!-- persons --> </td> <td width="5"><br> </td> <td align="left"> <table id="pictures" border="1" colspan="0" cellpadding="0" cellspacing="0" align="left"> <?php include('makecb4allpictures.php'); ?> </table> <!-- pictures --> </td> </tr> <tr> <td colspan="3" align="center"> <input type="submit" value="submit" name="Submit" /> <input type="reset" value="reset" name="Reset" /> </td> </tr> Form handler foreach ($_POST['PICTURES'] as $row=>$PICTURES) { $pictures = mysql_real_escape_string($row); $persons = $_POST['persons']; mysql_query('INSERT INTO relations (relPics, person) VALUES ($pictures, $persons)') or die(mysql_error()); echo $pictures." ".$persons; }
  3. set either the width or the height as a standard (like all pics new height is 200) then do some math to work out what the width of the pic is, make a new pic from the old pic with the new height and new width and then put it into a folder.
  4. <?php foreach ($_POST['PICTURES'] as $row=>$PICTURES) { $pictures = mysql_real_escape_string($row); $persons = $_POST['persons']; mysql_query('INSERT INTO relations (relPics, person) VALUES ($pictures, $persons)') or die(mysql_error()); } ?> basically what i have is a list of pictures with check boxes, I want those check boxes if selected to insert into a table with the "persons" variable. the code above is what i basically have where the check box is the PICTURES. the form names the variable as PICTURES and the value should be passed if it's been checked and only if it's been checked correct? this then forms an array, i thought this handled the array.
  5. How would you get it to insert multiple check boxes? because i have basically the same thing going on, but I can't seem to figure out how to get the checkbox values to insert using a for loop
  6. I'm stuck and i'm new at coding in general, so i would like some help please. what i want these two pages to do: 1. display a form consisting of radio buttons and check boxes. multiple selection of check boxes per radio button basically. I got this part done, it displays the data in the form which is being pulled from two separate tables. 2. Insert for each check box a record into a third table of the check box and radio button. Code is as follows... this is what i have thus far and I'm not really sure why it's not working from what i can see step by step it should be inserting the records, these arrays are the most terrible thing i can think of having to do... Code for the forms Generation of Checkboxes <?php $result = mysql_query("SELECT * FROM pictures"); $output="<tr>"; while($row = mysql_fetch_array($result)) { $counter = $counter + 1; $output .="<!--START ROW FOR checkbox " .$row['fileName']." --> "; $output .=" <td width=10 id=left10 align=left ><!--".$counter."--><br></td>"; $output .=" <td width=120 id=middle align=center valign=top >"; $output .=" <a href=".$fileURL."".$row['fileName']." ><img src=".$fileURL."THUMBS/".$row['fileName']." ></a><br>"; $output .=" <input type=checkbox name=PICTURES[] value=".$row['fileName']." />".$row[picTitle]; $output .=" </td>"; $output .=" <td width=10 id=right10 ><br></td>"; $output .="<!-- END ROW FOR checkbox " .$row['fileName']." -->"; if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; } } $output .="</tr>"; // open the file $fhandle = fopen( "FormParts/pictureCheckBoxes.php", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output );?> Code for the forms Generation of Radio buttons <?php $result = mysql_query("SELECT * FROM persons"); $output="<tr>"; while($row = mysql_fetch_array($result)) { $counter = $counter + 1; $output .="<!-- START ROW FOR Radio " .$row['name']."--> "; $output .=" <td width=10 id=left10 align=left valign=top >".$counter.". "; $output .=" </td>"; $output .=" <td width=120 id=middle align=left valign=top >"; $output .=" <input type=radio name=PERSONS value=".$row['name']." >".$row['name']; $output .=" </td>"; $output .=" <td width=10 id=right10 valign=top ></td>"; $output .="<!-- END ROW FOR Radio " .$row['Name']."--> "; if ( $counter % 1 == 0 ) { $output .= "</tr><tr>"; } } $output .="</tr>"; // open the file $fhandle = fopen( "FormParts/personsBullets.php", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output ); ?> so basically the form is <form id="makerelation" action="makerelation.php" method="POST"> <?php include ('FormParts/personsBullets.php'); include('FormParts/pictureCheckBoxes.php'); ?> <input type="submit" value="submit" name="Submit" /> <input type="reset" value="reset" name="Reset" /> </form> ok the form displays in html Perfectly fine. submission is where i'm having an issue. I don't know what i'm doing wrong with the insert part... <?php foreach ($_POST['PICTURES'] as $row=>$PICTURES) { $pictures = mysql_real_escape_string($pics); $persons = mysql_real_escape_string($_POST['persons'][$row]); mysql_query('INSERT INTO relations (relPics, person) VALUES($pictures, $persons)') or die(mysql_error()); } ?> so, what am i doing wrongly?
  7. ok, I'm pretty raw to PHP, but basically what i am doing here is making a thumbnail of an image that was uploaded. the codes here: function createAThumb( $pathToImages, $pathToThumbs, $fname, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { //echo "Creating thumbnail for {$fname} <br />"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } // close the directory closedir( $dir ); } where i am getting messed up is the $fname it's getting over wrote by the $info = pathinfo($pathToImages . $fname); line and i need that to make sure it's a jpg for the image to be resized. what should i try
  8. [quote author=jesirose link=topic=121311.msg498513#msg498513 date=1168128811] Did you check the actual database to see if the changes were made? With arrays, you need to do $_POST['CustCOMPANY'], surrounding the key in single quotes. [/quote] yeah i do have it dumping the data base array look down in my initial code :)
  9. yeah what it was is that i didn't have the {} around and the " ' order was messed up. I apologize for my lack of php skillz
  10. OH the " ' thing... thanks BTW do i need to include any classes for that sql injection?
  11. all i want this silly page todo is take info from a form, then do an update to the SQL record that it matches provided from the form so, form is this. [code=html] <form id="Customerinfo" action="CustomerFormUpdate.php" method="post"> <table border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <h3>Customer Account creation Information:</h3> </td> </table> <table border="0" cellpadding="0" cellspacing="0" align="center"> </tr> <tr> <td> User ID: </td> <td> <input type="text" name="CustLOGON" value="" size="45"/> </td> </tr> <tr> <td> User Pass: </td> <td> <input type="password" name="CustPASS" value="" size="45"/> </td> </tr> <tr> <td> Company Name: </td> <td> <input type="text" name="CustCOMPANY" value="" size="45"/> </td> </tr> <tr> <td> Company Contact First Name: </td> <td> <input type="text" name="CustFN" value="" size="45"/> </td> </tr> <tr> <td> <input type="Submit" value="Submit"/> <input type="Reset" value="Reset"/> </td> </tr> </table>  </form>[/code] and the php is this [code=php] <?php $con = mysql_connect("localhost", "username", "pass"); if (!$con)   {   die('Could not connect to the database Contact Site admin ' . mysql_error());   } mysql_select_db("mysqldb", $con); // TAKE RECORDS AND UPDATE BASED ON $_POST[CustLOGON] or user longon ID $sql='UPDATE `mysqldb` SET `CustCompany`="$_POST[CustCOMPANY]", `CustFn`="$_POST[CustFN]" WHERE `CustLogon`= "$_POST[CustLOGON]"'; if (!mysql_query($sql,$con))   {   die('Error Not able to update Values to table Check your syntax: ' . mysql_error());   } // DISPLAY UPDATED RECORDS $result = mysql_query("SELECT * FROM mysqldb"); echo "showing all records: <br/>"; while($row = mysql_fetch_array($result))   {   echo $row['CustLogon'] . " " . $row['CustCompany'] . " " . $row['CustFn'];   echo "<br />";   } mysql_close($con) ?> [/code] Now, when i run this i don't receive any errors and it displays the database records as if they were not touched. so i know it's in the where statement but why isn't it picking up the value? ??? ??? ??? what am i doing wrong here?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.