Jump to content

glen-rogers

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by glen-rogers

  1. Thanks for all your help guys, I feel like a complete moron now. I was never uploading the file to the server! I though I was working in localhost, but I had the actual site open instead! I'm a numpty.........................
  2. An error occured: 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 's Projects', 'Every month, STU does a "theme" that begins with the same letter o' at line 1 Query was: INSERT INTO projects VALUES (NULL, 'Stu's Projects', 'Every month, STU does a "theme" that begins with the same letter of the corresponding month. This month happens to be "JOLLY ROGER JUNE"... which is all things pirate based. This is primarily ALL images that STU would like to tattoo, at a reduced rate. Posts go on facebook regularly during the month and is all on a "first come first served" basis. Keep an eye out on the themes for the months ahead. There IS a full years listing on STU's facebook page.', '', '', '') I get the above error..................
  3. if (!empty($_REQUEST['atitle'])){ $title = $_REQUEST['atitle']; } else{ $title = NULL; } if (!empty($_REQUEST['acontent'])){ $content = $_REQUEST['acontent']; } else{ $content = NULL; echo "<span class='text'><p>Enter content for the News Item</p></span>"; } $title = mysql_real_escape_string(stripslashes($_POST['$title'])); $content = mysql_real_escape_string(stripslashes($_POST['$content'])); if ($title && $content){ $query = "INSERT INTO projects VALUES (NULL, '$title', '$content', '$remote_file', '$remote_file1', '$remote_file2')"; $result = mysql_query($query); if(!$result){ $error = 'An error occured: '. mysql_error().'<br />'; $error.= 'Query was: '.$query; echo $error; die($message); } This is my code
  4. Hi, its not doing anything with the single quote. If my form data has any single quote then I get a sql error! If my form data has double quotes and no single quotes then it gets added to mysql ok!
  5. Hi, I'm using mysql_real_escape_string(), but its not escaping single quote (it's escaping double quotes ok) Is there anything I can do/? Thanks
  6. Hi thanks for the reply. I have changed my php to this if (isset($_POST['submit'])){ foreach($_REQUEST['adate'] as $adate ){ mysql_query("INSERT INTO appointments VALUES ('', '$adate')"); } } Is this any closer?
  7. Hi, I have an html form that has 10 text field for trhe user too enter dates into. When the user clicks the submit button each text field should be added as a new record to a mysql table. The way I have it now if only 2 are filled in, rateher than making only 2 entries with the post data, it makes 20: the 2 that should be there and 8 empty ones, then repeats this, making 20. Can anyone offer assistance? Here is my code as it stands. <form class='form1' action='appointmentaddform.php' method='post' enctype='multipart/form-data' name='add_news-form' id='add_news_form'> <p><b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[0]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[1]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[2]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[3]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[4]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[5]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[6]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[7]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[8]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[9]' /></p> <br /> <input type='submit' id='submit' name='submit' value='Add Appointments' /> <input type='hidden' value='new' /> </form> <?php include '../inc/connect.php'; if (isset($_POST['submit'])){ while(!empty($_REQUEST['adate'])){ foreach($_REQUEST['adate'] as $adate ){ mysql_query("INSERT INTO appointments VALUES ('', '$adate')"); } } } ?> Thanks
  8. Thanks for the link, I read it and bookedmarked it! I came up with this code: <form action='subcategoryremoveform2.php' method='post' enctype='multipart/form-data' name='remove_subcategory_form' id='remove_subcategory_form'> <?php include 'admininc/categorydropdown.php'; ?> <b>Category</b> <select name="cat"> <?php echo $op;?> </select> <input type='submit' name='submit' value='Get Subcategories' /> <?php include '../inc/connect.php'; if(isset($_POST['submit'])){ $cat = intval($_POST['cat']); $data = mysql_query("SELECT * FROM subcategories WHERE cat_id IN ($cat) ") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo "<p>"; echo "<input type='checkbox' name='check[{$info['subcat_id']}]' />"; echo $info['subcategory']; echo "</span>"; echo "</p>"; } } ?> <p><input type='submit' name='remove' value='Remove Subcategories' /></p> </form> It does the job, but is a bit rough I think. Like the second submit button is there even if there are no subcategories! Is there a way to have the form so that button is not there without any subcategories?
  9. I was thinking maybe I could have the dropdown of categories and just have subcategories with checkboxes below, that match the category chosen in the dropdown?
  10. Hi I have a 'categories' mysql table and a 'subcategories' table. I need to make a form so the site owner can remove subcategories as needed. I was think of having a form with 2 dropdowns on it, the first to choose the category, the second to choose the subcategory. Then based on that selection another form is filled with the chosen subcategories? I'm unsure how to go about this though.. At the minut I have a form that is populated with all the subcategories, but there is no reference to which category they belong to. This is the file <form action='subcategoryremoveform.php' method='post' enctype='multipart/form-data' name='remove_subcategory_form' id='remove_subcategory_form'> <input type='submit' name='submit' value='Remove Subcategories' /> <?php include '../inc/connect.php'; $data = mysql_query("SELECT * FROM subcategories") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo "<p>"; echo "<input type='checkbox' name='check[{$info['subcat_id']}]' />"; echo $info['subcategory']; echo "</span>"; echo "</p>"; } ?> </form> <?php include '../inc/connect.php'; if(isset($_POST['check'])){ $chk = (array) $_POST['check']; $p = implode(',',array_keys($chk)); if ($sql = mysql_query("DELETE FROM subcategories WHERE subcat_id IN ($p)")){ header( 'Location: subcategoryremoveform.php' ); } else{ echo 'No subcategories have been removed'; } } ?> Can anyone offer advice on this?
  11. Thanks for that, all sorted now.........................
  12. Simple I'm sure, but how do I use nl2br with this line?? $returnHtml .= "<div class='imglabel'>{$row['product_description']}</div>"; Thanks
  13. Ah. What I was doing was this $output .= "<li><a href=$subcat_id class='subcategory'>$pair</a></li>"; When it should have been this $output .= "<li><a href=$subcat_id class='subcategory'>$subcategory</a></li>"; All sorted now! Thank you Glen
  14. That works! Thank you, I appreciate it. Just one more thing though. This- SELECT c.category, c.cat_id, GROUP_CONCAT(s.subcat_id,'|', s.subcategory ) AS sublist ... Put subcat_id in sublist with subcategory. So now my subcategory button go have subcat_id along with the subcategory text, like '1|dogs' '2|cats'..... Is there any way not to show the subcat_id in the button?
  15. This is all getting a bit confusing for me, as you can tell I'm a novice! I explode the sublist on this line $subcats = explode(",", $data['sublist']); How do I explode the pairs?
  16. Hey thanks for that. But now when i run that query in phpmyadmi it give me this category cat_id subcat_id sublist Ribbon 8 1 1|1 inch,2|7/8 inch,3|5/8 inch,4|3/8 inch
  17. It seems I'm only gett one subcat_id, even though there are four subcats!
  18. Sorry When I ran this SELECT c.category, c.cat_id, s.subcat_id, GROUP_CONCAT( s.subcategory ) AS sublist FROM categories AS c LEFT JOIN subcategories AS s ON c.cat_id = s.cat_id WHERE c.cat_id =8 GROUP BY c.cat_id ORDER BY c.cat_id LIMIT 0 , 30 8 is the cat_id of Ribbon which has subcat 1 inch, 7/8 inch, 5/8 inch, 3/8 inch I got this category cat_id subcat_id sublist Ribbon 8 1 1 inch,7/8 inch,5/8 inch,3/8 inch
  19. Where am I meant to be getting a result? This has come up SELECT c.category, c.cat_id, s.subcat_id, GROUP_CONCAT( s.subcategory ) AS sublist FROM categories AS c LEFT JOIN subcategories AS s ON c.cat_id = s.cat_id WHERE s.cat_id =1 GROUP BY c.cat_id ORDER BY c.cat_id LIMIT 0 , 30
  20. Wow, it all seems a bit above me! Do I not need all my fields though? In categories cat_id is the id of the category. In subcategories subcat_id is the id of the subcategory and cat_id is the same as cat_id in categories, so we know that subcategory belong to that category. In product subcat_id is the same as subcat_id in subcategories so we can tll the subcategory that product belongs to (if any). And cat_id is the same as cat_id in categories so we can tell what category the product belongs to. Have I got this all wrong?
  21. Ok, My tables are set up like this categories: cat_id - int(10) ai category - varchar(100) subcategories: subcat_id - int(10) ai subcategory - varchar(100) cat_id - int(10) products: id - int(10) ai product_name - varchar(100) product_description - text product_price - decimal(10, 2) product_image - varchar(100) cat_id - int(10) null(yes) subcat_id - int(10) null(yes) When I click on a category it displays all the products with that categories cat_id, as it should. When I click on to a any subcategory belonging to a given category it displays only one subcategories products, for every subcategory in that group. So for example, if i have a category 'animals' with subcategories 'dogs' 'cats' 'rabbits' and click on any one of them it will display whats is in 'cats' every time!
  22. Its still doing the same! showing the same data for every subcategory.
  23. Thanks. The page gives me this error now: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\wamp\www\acraftyaffair\inc\productmenu.php on line 5 on this line WHERE c.cat_id = $_GET['cat_id']
×
×
  • 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.