jazzman1 Posted August 1, 2012 Share Posted August 1, 2012 Yeah thanks, but that doesn't help. Could someone please explain it very simple terms what I need to do. Do I select "Reception Room" from the drop down menu and then convert one into "reception-room" and then enter that into 'linkcategory'? WHY DIDN'T YOU TRY DOING THIS? I smell a troll at this point. Or...., he/she doesn't understand EN very well. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 1, 2012 Share Posted August 1, 2012 1. He understands just fine. Look at the responses. 2. Based on his posts and your posts, I think you are the one who doesn't speak or understand English very well. I mean that as purely observational, not an insult. Also, most people aren't going to know what you mean by EN so write the whole word. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted August 1, 2012 Share Posted August 1, 2012 1. He understands just fine. Look at the responses. 2. Based on his posts and your posts, I think you are the one who doesn't speak or understand English very well. I mean that as purely observational, not an insult. Also, most people aren't going to know what you mean by EN so write the whole word. @off absolutely right Quote Link to comment Share on other sites More sharing options...
silkfire Posted August 1, 2012 Share Posted August 1, 2012 Or...., he/she doesn't understand EN very well. Trust me, Gareth is from UK so his English skills are definitely not the issue here. Most probably his logic is flawed and he becomes confused in the working process. Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted August 1, 2012 Author Share Posted August 1, 2012 This is the code I am using. As you can see I have tried to follow the process of adding 'Reception Room' and 'reception-room' into the 2 different columns. Should this process be working? <?php if(isset($_POST['form_id'])){ $category = mysql_real_escape_string(trim($_POST['category'])); $linkcategory = mysql_real_escape_string(trim($_POST['linkcategory'])); $firstname = mysql_real_escape_string(trim($_POST['firstname'])); $surname = mysql_real_escape_string(trim($_POST['surname'])); $email = mysql_real_escape_string(trim($_POST['email'])); $website = mysql_real_escape_string(trim($_POST['website'])); $company = mysql_real_escape_string(trim($_POST['company'])); $building = mysql_real_escape_string(trim($_POST['building'])); $streetname = mysql_real_escape_string(trim($_POST['streetname'])); $state = mysql_real_escape_string(trim($_POST['state'])); $postcode = mysql_real_escape_string(trim($_POST['postcode'])); $country = mysql_real_escape_string(trim($_POST['country'])); $aboutcompany = mysql_real_escape_string(trim($_POST['aboutcompany'])); $error = false; if(!isset($category) || empty($category)) { $error = "Please select a category."; } if(!isset($firstname) || empty($firstname)) { $error = "Please enter a First Name."; } if(!isset($surname) || empty($surname)) { $error = "Please enter a Surname."; } if(!isset($email) || empty($email)) { $error = "Please enter an email."; } if(!isset($website) || empty($website)) { $error = "Please enter a Website Domain."; } if(!isset($company) || empty($company)) { $error = "Please enter a Company Name."; } if(!isset($building) || empty($building)) { $error = "Please enter a Building Name or Number."; } if(!isset($streetname) || empty($streetname)) { $error = "Please enter a Street Name."; } if(!isset($state) || empty($state)) { $error = "Please enter a State."; } if(!isset($postcode) || empty($postcode)) { $error = "Please enter a Zip Code/Post Code."; } if(!isset($country) || empty($country)) { $error = "Please select your country."; } if(!isset($aboutcompany) || empty($aboutcompany)) { $error = "Please enter details about your company."; } if(!$error) { $query = mysql_query("INSERT INTO organiserdbase (category, linkcategory, firstname, surname, email, website, company, building, streetname, state, postcode, country, aboutcompany) VALUES ('".$category."', '".$linkcategory."', '".$firstname."', '".$surname."', '".$email."', '".$website."', '".$company."', '".$building."', '".$streetname."', '".$state."', '".$postcode."', '".$country."', '".$aboutcompany."')"); if($query) { } else { $error = "There was a problem with the submission. Please try again."; } } } ?> <div id="registerpagecell"> <div id="registerpageheaderorganiser"> Create Your Organiser Profile </div> <div id="registerform"> <form id="form_id" class="appnitro" method="post" action=""> <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?> <ul > <div id="forminputcell"> <li id="li_1" > <div id="forminputleft"> <label class="description" for="element_3">Your Job Role:</label> </div> <div id="forminputright"> <select class="element select medium" id="category, linkcategory" > </div> <option value="" selected="selected">Venue:</option> <option VALUES('Reception Room', 'reception-room') >Reception Room</option> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted August 1, 2012 Share Posted August 1, 2012 There are a ton of errors in your code Did you make any debugging and do you know what is this ? Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted August 1, 2012 Author Share Posted August 1, 2012 Well tbh it works without the linkcategory affect so I presumed it was okay. What errors are they? If it worked I assumed it had no errors. Quote Link to comment Share on other sites More sharing options...
Drummin Posted August 1, 2012 Share Posted August 1, 2012 Yes, even in the few lines of form code you've posted there are many errors. <div> within <ul> and "nesting" issues with </div> within <select> tags etc. Get tidy validator for firefox or another validator to check your code. Another issue is the <select> tag is not named. Any input field should be uniquely named. I'm sure it's been mentioned that creating an array would solve many of the issues you are trying to answer in having both a category name and link value. You can then easily check posted value against this array and use the array key to get the name. Here's a sample. <?php include "access.php"; $categories = array("reception-room"=>"Reception Room","hotel"=>"Hotel","night-club"=>"Night Club"); if(isset($_POST['category'])){ $_POST['category'] = trim($_POST['category']); if(!array_key_exists($_POST['category'],$categories)) { $error = "Please select a category."; } if(!isset($error)) { $category = mysql_real_escape_string($categories[$_POST['category']]); $linkcategory = mysql_real_escape_string($_POST['category']); $sql = "INSERT INTO organiserdbase (category, linkcategory) VALUES ('$category','$linkcategory')"; echo "$sql"; /* $query = mysql_query($sql); if($query) { } else { $error = "There was a problem with the submission. Please try again."; } */ } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title></title> </head> <body> <div id="registerpagecell"> <div id="registerpageheaderorganiser"> Create Your Organiser Profile </div> <div id="registerform"> <form id="form_id" name="form_id" class="appnitro" method="post" action=""> <?php if(isset($error)){ echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />";}?> <div id="forminputcell"> <div id="forminputleft"> <label class="description" for="element_3">Your Job Role:</label> </div> <div id="forminputright"> <select class="element select medium" name="category" id="category" > <option value="" selected="selected">Venue:</option> <?php foreach($categories as $key => $value){ $selected=(isset($_POST['category']) && $_POST['category']==$key ? ' selected="selected"' : ''); echo "<option value=\"$key\"$selected>$value</option>"; } ?> </select> </div> </div> <input type="submit" value="Submit" /> </form> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Drummin Posted August 1, 2012 Share Posted August 1, 2012 And with the str_replace() and strtolower() option as suggested several times. <?php include "access.php"; if(isset($_POST['category'])){ $_POST['category'] = trim($_POST['category']); if(!empty($_POST['category'])) { $error = "Please select a category."; } if(!isset($error)) { $category = mysql_real_escape_string($categories[$_POST['category']]); $linkcategory = str_replace(' ', '-',strtolower($_POST['category']); $linkcategory = mysql_real_escape_string($linkcategory); $sql = "INSERT INTO organiserdbase (category, linkcategory) VALUES ('$category','$linkcategory')"; echo "$sql"; /* $query = mysql_query($sql); if($query) { } else { $error = "There was a problem with the submission. Please try again."; } */ } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title></title> </head> <body> <div id="registerpagecell"> <div id="registerpageheaderorganiser"> Create Your Organiser Profile </div> <div id="registerform"> <form id="form_id" name="form_id" class="appnitro" method="post" action=""> <?php if(isset($error)){ echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />";}?> <div id="forminputcell"> <div id="forminputleft"> <label class="description" for="element_3">Your Job Role:</label> </div> <div id="forminputright"> <select class="element select medium" name="category" id="category" > <option value="" selected="selected">Venue:</option> <option value="Event Manager" >Event Manager</option> <option value="Event Managent Courses" >Event Managent Courses</option> <option value="Event Management Software" >Event Management Software</option> <option value="Entertainment Staff" >Entertainment Staff</option> </select> </div> </div> <input type="submit" value="Submit" /> </form> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted August 2, 2012 Share Posted August 2, 2012 There are a ton of errors in your code Did you make any debugging and do you know what is this ? can you be linient and just show the errors other than saying mate Quote Link to comment Share on other sites More sharing options...
Drummin Posted August 2, 2012 Share Posted August 2, 2012 I mentioned a few and also told you how you can see these for yourself by getting a validator add-on for firefox. Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted August 2, 2012 Share Posted August 2, 2012 most add-on validators are for html do you have a name for the one for php? Quote Link to comment Share on other sites More sharing options...
Drummin Posted August 2, 2012 Share Posted August 2, 2012 Well it's your html markup that really needed help. A good IDE editor will tell you when you have errors in your php. NetBeans is one option. Most of the errors I noticed had to do with nesting. For example if you want to "position" a selection box you don't put div tags around the <option> tags but rather the <selection> tags and you certainly need to watch nesting for example <b><i>word</i></b> not <b><i>word</b></i>. Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted August 2, 2012 Author Share Posted August 2, 2012 Drummin, Thanks you ever so much for putting that code up. Being able to see what I should be doing helps massively. It was very good of you to do that. IMHO people being prepared to show people what to do is that makes this a fantastic forum. It turns gobbledeegook into something visual. Thanks big time. I tried the first one and it returned the message "INSERT INTO organiserdbase (category, linkcategory) VALUES ('Reception Room','reception-room')" but didn't enter anything into the DB. I tried the second but it returned a syntax error, unexpected ';' I shall go through but its brilliant to see what I should be doing. Big Thanks. Quote Link to comment Share on other sites More sharing options...
Drummin Posted August 2, 2012 Share Posted August 2, 2012 If you notice in my samples, I just echo the query so you can SEE that the values are as expected. It's a good practice especially when having problems to echo the query to make sure all values are as expected. You can comment out or remove that "test" echo and un comment the query execution lines so it actually should do the query. Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted August 6, 2012 Share Posted August 6, 2012 so there is none for php? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 6, 2012 Share Posted August 6, 2012 Think about it. How could there be a firefox addon for debugging PHP. How would that work? Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 6, 2012 Share Posted August 6, 2012 Actually, there is a Fx plugin for debugging PHP scripts. However, you'll need to have Zend Server with the debug module loaded in order for it to do anything. Never tried it myself, as I just use Zend Studio's remote debugging feature whenever I need that kind of functionality. For checking the syntax, however, any IDE and/or PHP-enabled interpreter will do that for you; If you have a syntax problem, you get an error and the script won't execute. Asking for a PHP syntax validator is like asking for a test to find out if your car will start or not, without actually trying to start it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.