glen-rogers
Members-
Posts
26 -
Joined
-
Last visited
About glen-rogers
- Birthday 04/09/1980
Profile Information
-
Gender
Male
-
Location
Belfast, Northern Ireland
glen-rogers's Achievements
Newbie (1/5)
0
Reputation
-
mysql_real_escape_string() not escaping single quotes
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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......................... -
mysql_real_escape_string() not escaping single quotes
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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.................. -
mysql_real_escape_string() not escaping single quotes
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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 -
mysql_real_escape_string() not escaping single quotes
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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! -
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
-
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?
- 3 replies
-
- form
- multiple record
-
(and 1 more)
Tagged with:
-
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
- 3 replies
-
- form
- multiple record
-
(and 1 more)
Tagged with:
-
Populate a form based on dropdown selections.
glen-rogers replied to glen-rogers's topic in PHP Coding Help
Thank you -
Populate a form based on dropdown selections.
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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? -
Populate a form based on dropdown selections.
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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? -
Populate a form based on dropdown selections.
glen-rogers replied to glen-rogers's topic in PHP Coding Help
I'm unsure how to do joins! I'll give it a try! -
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?
-
Thanks for that, all sorted now.........................
-
Simple I'm sure, but how do I use nl2br with this line?? $returnHtml .= "<div class='imglabel'>{$row['product_description']}</div>"; Thanks
-
Only getting one subcat_id and apply to all subcategories
glen-rogers replied to glen-rogers's topic in PHP Coding Help
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