Jump to content

imdead

Members
  • Posts

    116
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

imdead's Achievements

Member

Member (2/5)

7

Reputation

  1. @ginerjm Thankyou, I understand that it's horribley messy and ugly. I've implemented some of your suggestions so far, although i'm still getting stuck on the SQL errors if i add any apostrophes to the statement <?php include"header.php"; error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $success=""; ?> <div id="info"> <?php if (isset($_SESSION['username'])) { $action = $_GET["action"]; ////DELETE A JOB //// if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } ////EDITING A JOB///// if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); if ($_POST) { $editid = $_GET['editid']; $job_title = htmlspecialchars($_POST["job_title"]); $job_description = htmlspecialchars($_POST["job_description"]); $job_type = $_POST["job_type"]; $job_area = $_POST["job_area"]; $hot_job = $_POST["hot_job"]; $nurse_vet = $_POST["nurse_vet"]; $query2 = "UPDATE jobs SET job_title='$job_title', job_description='$job_description', job_type='$job_type', job_area='$job_area', hot_job='$hot_job', nurse_vet='$nurse_vet' WHERE id='$editid' LIMIT 1"; $sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $query2"); }else { $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row["job_title"]); $job_description = htmlspecialchars($row['job_description']); $job_type = $row['job_type']; $job_area = $row['job_area']; $hot_job = $row['hot_job']; $nurse_vet = $row['nurse_vet']; echo("<form name='add' method='post' action='?action=edit&editid=$id'>"); echo("<input type='hidden' name='editid' value='$editid'>"); } } } ////ADDING A JOB//// if ($action == "add"){ $add = $_POST["add"]; $job_title = htmlspecialchars($_POST["job_title"]); $job_description = htmlspecialchars($_POST["job_description"]); $job_type = $_POST["job_type"]; $job_area = $_POST["job_area"]; $hot_job = $_POST["hot_job"]; $nurse_vet = $_POST["nurse_vet"]; $query = "INSERT INTO jobs (job_title, job_description, job_type, job_area, hot_job, nurse_vet) VALUES ('$job_title', '$job_description', '$job_type', '$job_area', '$hot_job', '$nurse_vet')"; $sql = mysql_query($query) or die (mysql_error()); } ///EMPTY //// if ($action == ""){ $job_title=""; $job_description=""; $job_type=""; $hot_job=""; $nurse_vet=""; $job_area=""; } ?> <form name='add' method='post' action='?action=add'> Job Title:<br /><input type='text' size='50' name='job_title' value="<?php echo htmlspecialchars($job_title); ?>"><br /> Job Description: <br /><textarea rows='10' cols='50' name='job_description'><?php echo htmlspecialchars($job_description); ?></textarea><br /> Job Type: <br /><select name='job_type'><option <?php if($job_type=="Permanent") echo 'selected="selected"'; ?>>Permanent</option><option <?php if($job_type=="Locum or Contract") echo 'selected="selected"'; ?>>Locum or Contract</option></SELECT><br /> Hot Job?<br /> Yes <input type='radio' name='hot_job' value='Yes' <?php if($hot_job=="YES") echo 'checked'; ?>> No <input type='radio' name='hot_job' value='no' <?php if($hot_job=="NO") echo 'checked'; ?>><br /> Nurse or Vet job?<br />Vet <input type='radio' name='nurse_vet' value='Vet' <?php if($nurse_vet=="Vet") echo 'checked'; ?>> Nurse <input type='radio' name='nurse_vet' value='Nurse' <?php if($nurse_vet=="Nurse") echo 'checked'; ?>><br /> Job Area:<br /><select name='job_area'><option <?php if($job_area=="East Anglia") echo 'selected="selected"'; ?>>East Anglia</option><option <?php if($job_area=="All UK") echo 'selected="selected"'; ?>>All UK</option><option <?php if($job_area=="London / South East") echo 'selected="selected"'; ?>>London / South East</option><option <?php if($job_area=="Midlands") echo 'selected="selected"'; ?>>Midlands</option><option <?php if($job_area=="North West") echo 'selected="selected"'; ?>>North West</option><option <?php if($job_area=="Northern Ireland") echo 'selected="selected"'; ?>>Northern Ireland</option><option <?php if($job_area=="Scotland") echo 'selected="selected"'; ?>>Scotland</option><option <?php if($job_area=="South") echo 'selected="selected"'; ?>>South</option><option <?php if($job_area=="South West") echo 'selected="selected"'; ?>>South West</option><option <?php if($job_area=="Southern Ireland") echo 'selected="selected"'; ?>>Southern Ireland</option><option <?php if($job_area=="Wales") echo 'selected="selected"'; ?>>Wales</option><option <?php if($job_area=="Yorkshire / North East") echo 'selected="selected"'; ?>>Yorkshire / North East</option></SELECT><br /> <input type='Submit' value='Submit'></div> <?php if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table cellspacing=20 cellpadding=20>"); if(isset($_GET["desc"])){ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID DESC"; }else{ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID ASC"; } echo("<td><a href=add_jobs.php?desc>Ref#:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet:</td><td>Edit:</td><td>Delete:</td><td>Hot:</td>"); ?> <form name='hotbox' action='hot_update.php' method='POST'> <?php $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row['job_title']); $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $nurse_vet = $row['nurse_vet']; $hotbox = $row['hot_job']; $position=18; $job_description2 = substr($job_description, 0, $position); ECHO "<tr><td><strong>$id</strong></td>"; ECHO "<td><strong>$job_title</strong></td>"; ECHO "<td><strong>$job_description2 ...</strong></td>"; ECHO "<td><strong>$job_type</strong></td>"; ECHO "<td><strong>$job_area</strong></td>"; ECHO "<td><strong>$nurse_vet</strong></td>"; ECHO "<td><a href='add_jobs.php?action=edit&editid=$id'>Edit</a></td>"; ECHO "<td><a href='add_jobs.php?action=delete&delid=$id'>Delete</a></td>"; ?> <td><input name="ONOFF[]" type="checkbox" value="<?php echo $row['id']; ?>" <?php if($row['hot_job'] == 'YES') { echo "checked='checked' "; } ?>/></td></tr> <?php } ?></p><input type='Submit' value='Update'></form></table> </div> <?php }else{echo'Stop hacking';} include"footer.php"; ?>
  2. Thanks very much, that worked for displaying the title, although when editing I still get this error if there is an apostrophe Editing a Job:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'r', job_description='tyrtyff', job_type='Permanent', job_area='East Anglia', hot' at line 1 IN UPDATE jobs SET job_title='twetwe ' r', job_description='tyrtyff', job_type='Permanent', job_area='East Anglia', hot_job='no', nurse_vet='Nurse' WHERE id='473' LIMIT 1
  3. Hello everyone, Please bear with me, this is really messy I have a few questions, i've tried to render 3 different pages, Default, Edit and Delete, however the edit and default page, keep messing with each other and screwing the forms. <?php if (isset($_SESSION['username'])) { if ($_SESSION['userlevel'] = '3'){ $action = $_GET["action"]; ////DELETE A JOB //// if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } ////EDITING A JOB///// if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); if ($_POST) { $editid = $_GET['editid']; $job_title = htmlspecialchars($_POST['job_title']); $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $query2 = "UPDATE jobs SET job_title='$job_title', job_description='$job_description', job_type='$job_type', job_area='$job_area', hot_job='$hot', nurse_vet='$nurse_vet' WHERE id='$editid' LIMIT 1"; $sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $query2"); }else { $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query(htmlspecialchars($s)) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row["job_title"]); $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $hot = $row['hot']; $nurse_vet = $row['nurse_vet']; echo("<form name='add' method='post' action='?action=edit&editid=$id'>"); echo("<input type='hidden' name='editid' value='$editid'>"); } } } ////ADDING A JOB//// if ($action == "add"){ $add = $_POST['add']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $id = mysql_insert_id(); $query = "INSERT INTO jobs (id, job_title, job_description, job_type, job_area, hot_job, nurse_vet) VALUES ('$id', '$job_title', '$job_description', '$job_type', '$job_area', '$hot', '$nurse_vet')"; $sql = htmlspecialchars(mysql_query($query)) or die (mysql_error()); } ///EMPTY //// if ($action == ""){ $job_title=""; $job_description=""; } ?> <strong>Add A New Job!</strong> <br /> <br /> <form name='add' method='post' action='?action=add'> <input type='hidden' name='?action=add'> Job Title:<br /><input type='text' size='50' name='job_title' value='<?php echo htmlspecialchars($job_title); ?>'><br /> Job Description: <br /><textarea rows='10' cols='50' name='job_description'><?php echo $job_description; ?></textarea><br /> Job Type: <br /><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT><br /> Hot Job?<br /> Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked><br /> Nurse or Vet job?<br />Vet <input type='radio' name='nurse_vet' value='Vet'> Nurse <input type='radio' name='nurse_vet' value='Nurse' checked><br /> Job Area:<br /><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT><br /> <input type='Submit'></div> <?php if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table class=main cellspacing=20 cellpadding=20>"); if(isset($_GET["desc"])){ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID DESC"; echo("<td><a href=add_jobs.php>Ref#:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet:</td><td>Edit:</td><td>Delete:</td><td>Hot:</td>"); }else{ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID ASC"; echo("<td><a href=add_jobs.php?desc>Ref#:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet:</td><td>Edit:</td><td>Delete:</td><td>Hot:</td>"); } ?> <form name='hotbox' action='hot_update.php' method='POST'> <?php $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row['job_title']); $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $nurse_vet = $row['nurse_vet']; $hotbox = $row['hot_job']; $position=18; $job_description2 = substr($job_description, 0, $position); ?> <tr><td><strong><?php echo $id; ?></strong></td><td><strong><?php echo $job_title; ?></strong></td><td><strong><?php echo $job_description2; ?>...</strong></td><td><strong><?php echo $job_type; ?></strong></td><td><strong><?php echo $job_area; ?></strong></td><td><strong><?php echo $nurse_vet; ?></strong></td><td><a href='add_jobs.php?action=edit&editid=<?php echo $id; ?>'>Edit</a></td><td><a href='add_jobs.php?action=delete&delid=<?php echo $id; ?>'>Delete</a></td><td><input name="ONOFF[]" type="checkbox" value="<?php echo $row['id']; ?>" <?php if($row['hot_job'] == 'YES') { echo "checked='checked' "; } ?>/></td></tr> <?php } ?></p><input type='Submit' value='Update'></form></table> </div> <?php }else{echo'Stop hacking';}} ?> < Also you see how the Title wont display the whole title due to the " ' " How do i prevent this? This is how the page renders
  4. Username: test Password: test it'd be eaiser if people registered though so they game was functional
  5. Hey guys, I've tried my hardest to create an online game, give it a whirl. i'll unpause when we get to 20 players. There's a help page to get you started. Post here with any bugs or comments! http://www.delusionalkev.com/sn/ Thankyou http://www.delusionalkev.com/sn/text.txt
  6. Thankyou Psycho and requinix I've used your tips and corrected everything, cheers
  7. Hiya i'm working on a project, which involves a list of checkboxes which are automaticly populated by the database which is currently working at while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $hotbox = $row['hot_job']; ?> <form name='hotbox' action='hot_update.php' method='POST'> <tr><td><strong><?php echo $id; ?></strong></td> <td><input name="ONOFF<? echo $row['id']; ?>" type="checkbox" id="ONOFF" value="1" <?php if ($row['hot_job'] == 'YES') { echo "checked";} else {} ?> </td></tr> <?php } ?> however when the user has unchecked/checked the correct boxes and clickes update, nothing changes. Here is my current code foreach($_POST['id'] as $id) { $onoff = 0; if (isset($_POST["ONOFF".$id])) { $onoff = 1; } if($onoff == 1) { $sql1="UPDATE jobs SET hot_job='".$onoff."' WHERE id='".$id."'"; } else { $sql1="UPDATE jobs SET hot_job='".$onoff."' WHERE id='".$id."'"; } echo $id; echo $onoff; $result1=mysql_query($sql1); } ?> The mysql setup is id hot_job 1 YES 2 YES 3 NO 4 YES ect Any help would be greatly appreciated
  8. resolved by using <!--[if IE]> <script> document.createElement('header'); document.createElement('nav'); document.createElement('section'); document.createElement('article'); document.createElement('aside'); document.createElement('footer'); document.createElement('hgroup'); </script> <![endif]-->
  9. I've already tried this and matched up the website to the clean markup, yet this makes the website broken in all browsers? Edit: i just rechecked using the correct markup and 'This document was successfully checked as HTML5!'
  10. Hey everyone, i'm helping create a website for a friend over at http://www.kevin-cornish.com/jerrihart/history.html if you check it out you can see that the page loads perfectly on every browser however, looks horrible in IE8. Any suggestions?
  11. Hey guys i have a problem, I have a form to upload 2 image files however sometimes i want to only upload the one file, but if i only upload one image, it tells me that it can't upload because there is no name for the second image. I tried fixing it with if (isset($fieldname2)) however i just realised that $feildname2 is always set so im not quite sure how to fix? ($action == "add"){ $add = $_POST['add']; $reference = $_POST['reference']; $category = $_POST['category']; $sub_cat = $_POST['sub_cat']; $fieldname = 'file'; $fieldname2 = 'file2'; error_reporting(E_ALL); ini_set('display_errors',1); is_uploaded_file($_FILES[$fieldname]['tmp_name']); getimagesize($_FILES[$fieldname]['tmp_name']); if (isset($fieldname2)) { is_uploaded_file($_FILES[$fieldname2]['tmp_name']); getimagesize($_FILES[$fieldname2]['tmp_name']); } $now = time(); while(file_exists($uploadFilename = $uploadsDirectory.$_FILES[$fieldname]['name'])) { $now++; } if (isset($fieldname2)) { while(file_exists($uploadFilename2 = $uploadsDirectory.$_FILES[$fieldname2]['name'])) { $now++; } } move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename); if (isset($fieldname2)) { move_uploaded_file($_FILES[$fieldname2]['tmp_name'], $uploadFilename2); } $sqlname = $_FILES[$fieldname]['name']; if (isset($fieldname2)) { $sqlname2 = $_FILES[$fieldname2]['name']; } $id = mysql_insert_id(); $query = "INSERT INTO cakes (id, reference, category, sub_cat, image, image2) VALUES ('$id', '$reference', '$category', '$sub_cat','$sqlname','$sqlname2')"; $sql = mysql_query($query) or die (mysql_error()); } echo("<form name='add' method='post' enctype='multipart/form-data' action='?action=add'>"); echo("<input type='hidden' name='MAX_FILE_SIZE' value='3000000"); echo("<input type='hidden' name='?action=add'>"); echo("<table class=main cellspacing=0 cellpadding=2 width=60%>"); echo("<tr><td>Reference: </td><td align='right'><input type='text' size=50 name='reference' value='$reference'></td></tr>"); echo("<tr><td>Category: </td><td align='center'><select name='category'><option>Occasional</option><option>Special</option><option>Figures</option><option>Novelty</option><option>Wedding</option></SELECT></td></tr>"); echo("<tr><td>Sub Category: </td><td align='center'><select name='sub_cat'><option></option><option>Birthday</option><option>Anniversary</option><option>Christmas</option><option>Christening</option><option>Valentine</option><option>Mothers Day</option><option>Fathers Day</option><option>Easter</option></select></td></tr>"); echo("<tr><td>Cake Image: </td><td align='center'><input id='file' type='file' name='file'></td></tr>"); echo("<tr><td>Cake Image 2: </td><td align='center'><input id='file2' type='file' name='file2'></td></tr>"); echo("Before uploading an image please resize the image to 290px x 218px"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>");
  12. Hello all, im creating a website for a client and have ran into a brick wall. I'm using javascript to magnify images, like this $html .= '<p><img src="../../../images/cakes/'.$image.'" class="magnify" style="clear: both;" height="289px" width="177px" alt="NO IMAGE UPLOADED"></img><br />'; Which is working fine, however i have added a button below saying 'View another image' which on click i want to display the other image, however it is enlarging the 'View another image' button instead of the actual picture, this is the code. $html .= '<img class="magnify" src="../../../images/view-another.gif"><img src="../../../images/cakes/'.$image.'"></img></img></p>';
  13. aha with some slight changes thats got it thankyou very much, with the cols though depending on how many it needs, should i use a count first and then use the result as the var?
  14. I've tried taking the <P> tags out, and this was the result
×
×
  • 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.