Jump to content

dazzclub

Members
  • Posts

    106
  • Joined

  • Last visited

Everything posted by dazzclub

  1. Hi all, I'm looking for some pointers in regards to my form.. How would I firstly trim the $_POST value of the variables that come through via the form (I'm only using one for now)..I know I'm making a right dogs dinner of it. In my head I'm thinking, trim all the posts first before i even assign a variable to it ( i dont know if thats possible), then use an array for when more values start coming through via the form. You know as i make a contact form that requires more data from the user.. <?php require_once '../connection/dbconfig.php'; include_once('../connection/connectionz.php'); //get the values //Get the request method from the $_SERVER $requestType = $_SERVER['REQUEST_METHOD']; //this is what type //echo $requestType ; if($requestType == 'POST') { //now trim all $_POSTS $search_products = trim($_POST['search_products']); // if(empty($search_products)){ echo '<h4>You must type a word to search!</h4>'; }else{ $make = '<h4>No match found!</h4>'; $new_search_products = "%" . $search_products . "%"; $sql = "SELECT * FROM product WHERE name LIKE ?"; //prepared statement $stmt = mysqli_stmt_init($conDB); //prepare prepared statements if(!mysqli_stmt_prepare($stmt,$sql)) { echo "SQL Statement failed"; }else{ //bind parameters to the placeholder mysqli_stmt_bind_param($stmt, "s", $new_search_products ); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); echo'<h2> Search Result</h2>'; echo 'You searched for <strong><em>'. $search_products.'</em></strong>'; while($row = mysqli_fetch_assoc($result)){ echo '<h4> (ID : '.$row['pid']; echo ') Book Title : '.$row['name']; echo '</h4>'; } } } } ;?> If any one can shed some light on this, or some pointers..that would be very nice... Thanks Darren
  2. I think the problem has been was that the variable i need to echo out the image was only set after i uploaded the file only. So obviously when i refresh the page it's looking at the variable and it's empty, because nothing has been uploaded.. so my first solution, because it's not displaying after refresh, is to query the database to retrieve the most recent INSERT via ID... I think having the ID stops two people retrieving the same image? If not, I'll have to query the database and use their username has a way of identifying their own recent INSERT.. Well, that's my thinking..
  3. Hi mac_guyver, That was a typing error on my behalf...so now this particular code looks like.. echo '<img src="img/tees/'.$image_file.'" />'; Now, it uploads and you can see the image but disappears when i refresh the page....I'm thinking the problem is how i laid out the code and in what order..I'm guessing here..maybe $image_file holds the file name just for the upload only? Thanks
  4. Hi there, I'm trying to get my image to still be visible on a page even after I refresh it. I've managed to insert the file name into the database, store it temporarily and then move it to the right folder.. When i upload (or INSERT INTO a table) it, you can instantly see the image, it just disappears when for example I'll press enter in the browsers url or when i refresh it. Here is my current code $target = "img/tees/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $image_file = basename( $_FILES['uploaded']['name']) ; $ok=1; //remember to sanitize $_POST if($_POST['upload']){ //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ".basename( $_FILES['uploadedfile']['name']). " has been uploaded"; $display_image = '<img src="'.$target.'" title="" alt="" />'; global $dbc; $sql = "INSERT INTO full_range (image) VALUES ('$image_file')"; $result = mysqli_query($dbc, $sql) or trigger_error("SQL", E_USER_ERROR); if($result) { echo 'All done'; } } else { echo "Sorry, there was a problem uploading your file."; } } } And here is the code that displays the image file that's been inserted... echo '<img src="img/tees'.$image_file.'" />'; I've read on the internet that I may need to do pass an img variable to another page such as, display.php?img=name_of_img and the have that in the image src file... <img src="display.php?img=name_of_img" /> but I think I could be getting ahead of myself and making a mountain out of a mole hill.. Any pointers to what I'm doing wrong would be great
  5. Thank you so much, it worked.. Here's the full code if anyone finds it usefull... function search_applications() { global $dbc; echo '<form method="post" action="" id="search">'. "\n"; echo '<label for="search_applications">Search for an application</label>'. "\n"; echo '<input type="text" name="search_applications" />'. "\n"; echo '<input type="submit" name="submit" />'. "\n"; echo '</form>'. "\n"; if(isset($_POST['submit'])){ $search_applications = $_POST['search_applications']; if ($search_applications == "") { echo "<p>You forgot to enter a search term"; } //if (preg_match("/\b$search_applications\b/i")){ if(preg_match("/^[ a-zA-Z]+/", $search_applications)){ //for testing the variables //echo $search_applications; $sql="SELECT title, category, content FROM distributors_content WHERE title LIKE '%" . $search_applications . "%' OR category LIKE '%" . $search_applications ."%' OR content LIKE '%" . $search_applications ."%'"; $result=mysqli_query($dbc, $sql); if(mysqli_num_rows($result) == 0){ echo "There were no matches!"; } //-create while loop and loop through result set while($row=mysqli_fetch_array($result)){ $title =$row['title']; $category=$row['category']; $content=$row['content']; //-display the result of the array echo "<ul>\n"; echo '<li> <a href="index.php?article='.$row['title'].'&&page=application" title=""> '.$title . ' ' . $category . '</a></li>'."\n"; echo "</ul>"; } } } } Thanks again
  6. Hi guys and girls, I am having trouble finding out wether the query made no matches rather than just displaying the matches. So what I would want is for the search term to look at the database, and if there's not matches then say, "No match for your search term" function search_applications() { global $dbc; echo '<form method="post" action="" id="search">'. "\n"; echo '<label for="search_applications">Search for an application</label>'. "\n"; echo '<input type="text" name="search_applications" />'. "\n"; echo '<input type="submit" name="submit" />'. "\n"; echo '</form>'. "\n"; if(isset($_POST['submit'])){ $search_applications = $_POST['search_applications']; if ($search_applications == "") { echo "<p>You forgot to enter a search term"; } //if (preg_match("/\b$search_applications\b/i")){ if(preg_match("/^[ a-zA-Z]+/", $search_applications)){ //for testing the variables //echo $search_applications; $sql="SELECT title, category, content FROM distributors_content WHERE title LIKE '%" . $search_applications . "%' OR category LIKE '%" . $search_applications ."%' OR content LIKE '%" . $search_applications ."%'"; $result=mysqli_query($dbc, $sql); //-create while loop and loop through result set while($row=mysqli_fetch_array($result)){ $title =$row['title']; $category=$row['category']; $content=$row['content']; //-display the result of the array echo "<ul>\n"; echo '<li> <a href="index.php?article='.$row['title'].'&&page=application" title=""> '.$title . ' ' . $category . '</a></li>'."\n"; echo "</ul>"; } }else{ echo "<p>Enter another search term</p>"; } } } Any pointers would be good Thank you
  7. Hello there, Im trying to get my head around sessions and passing the data between pages. So I'm attempting to build a very basic questionnaire. My problem comes when i try to go back to a previous page. I want the user to be able to go back and change their answers if need be. This is the code taken from page one. <?php session_start(); //sends enquiries //page 1 answers $_SESSION['day_1_fridge_indicator'] = $_POST['day_1_fridge_indicator']; $_SESSION['day_2_fridge_indicator'] = $_POST['day_2_fridge_indicator']; $_SESSION['day_3_fridge_indicator'] = $_POST['day_3_fridge_indicator']; ?> and on the second page it looks like this; <?php session_start(); //sends enquiries //page 1 answers $q1 = $_SESSION['day_1_fridge_indicator']; $q2 = $_SESSION['day_2_fridge_indicator']; $q3 = $_SESSION['day_3_fridge_indicator']; ?> If you want a working demo then please visit here >> http://www.lcrhallcrest.com/bmpa-survey/ Thanks for any type of help would be great.
  8. Your right made sense, thank you. Here is the updated code; if(isset($_POST['submitted'])) { $recommend = $_POST['recommend']; //has radio been checked if($recommend == '') { $fail = "<div id=\"fail\"><p>You must select a field before you proceed to the next page</p></div> "; }else{ //$confirm = 'yes '.$contact_us.''; header('Location:page7.php'); } } Thank you Darren
  9. Hi there, I'm working on a questionnaire and I need to ensure that the users cant proceed to the next page without selecting/completing a field. I need to check multiple variables as the path the user takes depends on the submitted questions. So I tried to use if(!isset($response_time_email || $effectivenes ){ but I keep getting stumped. Here is the original code; if(isset($_POST['submitted'])) { $response_time_email = $_POST['response_time_email']; //has radio been checked if(!isset($response_time_email)){ $fail = "<div id=\"fail\"><p>You must select a field before you proceed to the next page</p></div> "; }else{ if(isset($response_time_email)) { //$confirm = 'yes '.$contact_us.''; header('Location:page3.php'); } } } Any help would be great, thank you. Darren
  10. Hi there, I am testing my form so when i press submit i get several variables being displayed as Notice: Undefined index: variable name here I looked at to see if the spelling is right so to rule any further complications these variables now use lower case had include no special characters. These variables are checkboxes on my form.. to see it live visit http://www.lcrhallcrest.com/education.php Here is the actual code function sample_pack() { //$mail=ini_set(SMTP,"smtp.orange.co.uk"); //$mail=ini_set(smtp_port,25); $success =''; $fail = ''; $Error_Name = ''; $ErrorTel = ''; $ErrorEmail = ''; //this will check to see if the form has been completed accordingly if(isset($_POST['submitted'])) { // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $company_name = $contact_name = $tel_number = $email_address = $address = $address_two = $postcode = $city = $conductivitybars = $inks = $lcsheets = $radiationdiscs = $thermometers = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['company_name'])) { $company_name = addslashes ($trimmed['company_name']); } if (preg_match ('/^[A-Z \'.-]{2,60}$/i', $trimmed['contact_name'])) { $contact_name = addslashes ($trimmed['contact_name']); } else { $Error_Name = '<strong class="Error">Please enter a contact name</strong>'; } if ($tel_number= ereg_replace("[^0-9]", "", $trimmed['tel_number'])) { $tel_number = addslashes ($trimmed['tel_number']); } else { $ErrorTel = '<strong class="Error">Please enter your telephone number</strong>'; } // Check for an email address: if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email_address'])) { $email_address = addslashes ( $trimmed['email_address']); } else { $ErrorEmail = '<strong class="Error">Please enter a valid email address</strong>'; } if (preg_match ('/^[A-Z \'.-0|1|2|3|4|5|6|7|8|9]{2,20}$/i', $trimmed['address'])) { $address = addslashes ($trimmed['address']); } else { $address = 'FALSE'; } if (preg_match ('/^[A-Z \'.-0|1|2|3|4|5|6|7|8|9]{2,20}$/i', $trimmed['address_two'])) { $address_two = addslashes ($trimmed['address_two']); } else { $address_two = 'FALSE'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['city'])) { $city = addslashes ($trimmed['city']); } else { $city = 'FALSE'; } if (preg_match ('/^[A-Z \'.-0|1|2|3|4|5|6|7|8|9]{2,20}$/i', $trimmed['postcode'])) { $postcode = addslashes ($trimmed['postcode']); } else { $postcode = 'FALSE'; } //product checkboxes if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['conductivitybars'])) { $conductivitybars = addslashes($trimmed['conductivitybars']); } else { $conductivitybars = 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['inks'])) { $inks = addslashes($trimmed['inks']); } else { $inks= 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['lcsheets'])) { $lcsheets = addslashes($trimmed['lcSheets']); } else { $lcsheets= 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['radiationdiscs'])) { $radiationdiscs = addslashes($trimmed['radiationdiscs']); } else { $radiationdiscs= 'no'; } if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['thermometers'])) { $thermometers = addslashes($trimmed['thermometers']); } else { $thermometers= 'no'; } //addiotional check boxes if ($company_name && $contact_name && $tel_number && $email_address && $address && $address_two && $city && $postcode && $conductivitybars && $inks && $lcsheets && $radiationdiscs && $thermometers ) { // If everything's OK... //insert into database //$q = "INSERT INTO enquiries (first_name, last_name, email, title, company, address_1, address_2, post_code, city, state, country, tel, comments, enquiry_date) VALUES ('$first_name', '$last_name', '$email', '$title', '$company', '$address_1','$address_2', '$post_code','$city', '$state', '$country', '$tel', '$comments', NOW() )"; //$r = mysqli_query ($dbc, $q) or 'insert failed something messed up'; //if (mysqli_affected_rows($dbc) == 1) { { //send mail $headers = "From: LCR Hallcrest \n "; $headers .= " \r\n"; $headers .= "Reply-To: no-replay@lcrhallcrest.com \r\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $body = "Dear <strong>$contact_name</strong> <br /> <br /> We are happy you have spent some time completing our sample pack form. <br /> <br /> Visit <a href=\"http://www.lcrhallcrest.com\" title=\"temperature Sensitive applications\">http://www.lcrhallcrest.com</a> for Temperature Sensitive applications. <br /> <br /> <a href=\"mailto:myemail\" target=\"_blank\" class\"enquiry\">Admin@lcrhallcrest.com</a><br /> <span style=\"font-size:8pt;\">Worlds Largest Producer of Colour Changing Temperature Sensitive - Indicating Graphic Devices and Materials</span> \n\n"; mail($trimmed['email_address'], 'Thank you for visiting LCR Hallcrest', $body, $headers); //finish the page //send enquiry to admin as well //send email aswell $sendTo = "myemail"; $subject = "Thermosmart Sample Pack Request"; $headers = "From:From \n "; $headers .= " $contact_name \r\n"; $headers .= " BCC: myemail \r\n"; $headers .= "Reply-To: no-replay@lcrhallcrest.com\r\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $message ="Hi Linda,<br /> <br /> This email is to inform you that <span style=\"font-weight:bold;\">$contact_name</span> made a sample request.<br /> <br /> <br /> <p>Company: <strong>$company_name</strong></p> <p>Address:<br/> <strong> $address<br /> $address_two<br /> $city<br /> $postcode </strong> </p> <p>tel: <strong>$tel_number</strong></p> <p>email: <strong><a href=\"mailto:$email_address\">$email_address</a></strong></p> <p>Contact name: <strong>$contact_name</strong></p> <p><strong>Requested sample pack</strong>:</p> <p>conductivity bars: <strong>$conductivitybars</strong></p> <p>inks: <strong>$inks</strong></p> <p>lc Sheets: <strong>$lcsheets</strong></p> <p>radiation discs: <strong>$radiationdiscs</strong></p> <p>thermometers: <strong>$thermometers</strong></p> <br /> <br /> From<br /> <a href=\"mailto:myemail\" target=\"_blank\" class\"enquiry\">Admin@lcrhallcrest.com</a><br /> <span style=\"font-size:7pt;\">LCR Hallcrest</span>"; mail($sendTo, $subject, $message, $headers); } $success = "<strong class=\"success\">Thank you <strong>$contact_name</strong> for your enquiry!!</strong>"; // Stop the page. } else { // If it did not run OK. $fail = '<strong id="fail">Can you make sure the required fields have been completed.</strong>'; } } echo ' <form method="post" action="education.php" class="sample_pack"> '.$success.''.$fail.' <fieldset> <legend>Complete form for sample pack</legend> <strong class="required_field">*Required field</strong> <p><label for="company_name">Company Name</label><input type="text" name="company_name" id="company_name" tabindex="1" value=""></p> <p><label for="contact_name" ><span>required</span>'.$Error_Name.'Contact Name</label><input type="text" name="contact_name" id="contact_name" tabindex="2" id="name"></p> <p><label for="tel_number"><span>required</span>'.$ErrorTel.'Tel Number</label><input type="text" name="tel_number" id="tel_number" tabindex="3"></p> <p><label for="email_address"><span>required</span>'.$ErrorEmail.'Email</label><input type="text" name="email_address" id="email_address" tabindex="4"></p> <p><label for="address"><span>required</span>Address</label> <input type="text" name="address" id="address" tabindex="5"></p> <p><label for="address_two"><span>required</span>Address 2</label><input type="text" name="address_two" id="address_two" tabindex="6"></p> <p><label for="city">City</label> <input type="text" name="city" id="city" tabindex="7"></p> <p><label for="postcode"><span>required</span>Postcode</label><input type="text" name="postcode" id="postcode" tabindex="8"></p> </fieldset> <fieldset class="packs"> <legend>Request a sample pack</legend> <ul> <li><input type="checkbox" name="conductivitybars" id="conductivitybars" value="yes" tabindex="9" /><label for="conductivityBars">Conductivity bars</label></li> <li><input type="checkbox" name="inks" id="inks" value="yes" tabindex="10" /><label for="inks">ink</label></li> <li><input type="checkbox" name="lcsheets" id="lcsheets" value="yes" tabindex="11" /><label for="lcsheets">lc sheets</label></li> <li><input type="checkbox" name="radiationdiscs" id="radiationdiscs" value="yes" tabindex="12" /><label for="radiationdiscs">radiation discs</label></li> <li><input type="checkbox" name="thermometers" id="thermometers" value="yes" tabindex="13" /><label for="thermometers">thermometers</label></li> </ul> <p><input type="submit" value="submit" name="submit" tabindex="14"/> <input type="hidden" name="submitted" value="TRUE" /></p> </fieldset> </form>'; } [code] Any help would be great.. Thanks Darren
  11. I've been working on a preg_match for an input that would contain a telephone number.. As the web is international people may put in their characters such as braces, dashes, or plus or even periods....so in essence they could enther a string like this into my tel input field (00+4) 123.123.123 Ive been trying to create a preg_match to expect this, but obviously it doesnt work if (preg_match('/^[0-9][\*( \*)\*.\*+]$/i',$trimmed['tel_number'])) { $tel_number = addslashes ($trimmed['tel_number']); } else { $ErrorTel = '<strong class="Error">Please enter your telephone number</strong>'; } if anyone could point me in the right direction that would be great... Thanks Darren
  12. Hi Dreamwest, Thanks for getting back to me on this... I have just uploaded .htaccess file and i have tested the url http://www.colourchange.com/thermometers/room it displays the correct page but without any of the css styling attached...It should remsemble this page http://www.colourchange.com/thermometers.php?products=thermometers&type=room Should I do anything differently?? With the new url /thermometers/room, would I then replace the old one by editing the actual xhtml file. As the link doesnt seem to change when i use it, it still displays the old one. Thanks for your help on this, i know im asking too much but I'm so lost. Thanks Darren
  13. Hi guys, With the help of a user called thorpe he was able to rerwrite a rule i was after but i wanted to ask a few more questions. As mentioned Thorpe wrote this for me RewriteEngine on RewriteRule ^/thermometers/room$ thermometers.php?products=thermometers He also suggested that a more dynamic rule be used instead. What I would like to do is when the users request thermometers.php?products=thermometers by pressing a link the user would then see thermometers/room/in the browser instead. For this to work would i then need to create the actual folders on my server? i.e thermometers/room/? Can someone point me in the right direction as what would be best please. Thanks for your help. Regards Dazzclub
  14. Hi there, Thanks for your reply and your help. Let me just confirm things, the orginal url is http://www.colourchange.com/thermometers.php?products=thermometers but if possible turn it into http://www.colourchange.com/thermometers.php/products/thermometers or just http://www.colourchange.com/thermometers.php/products/ As it stands, i only have a few urls that need changing like this. Is this possible? Thanks for your help.
  15. Hello all, I have a site im working and it has some urls that i would to give a make over. one url is http://www.colourchange.com/thermometers.php?products=thermometers I would like to turn this into http://www.colourchange.com/thermometers/room/ Here is what i have so far in my .htaccess file RewriteEngine on RewriteRule ^/(.*)/(.*)/thermometers.php?products=thermometers$ http://www.colourchange.com/thermometers/room/ I am currently running this locally, so when i can do it i can then make the neccessary changes to the live site. Thanks, any help or tips would be nice. Dazzclub
  16. Hi all, i would like to display my date as day.month.year, ie (my birthday) 29.10.82 here is what i have got so far; function InTheNews() { global $dbc; $query = "SELECT id,title, content,date FROM news_headlines ORDER BY id"; $result = mysqli_query ($dbc, $query)or die(mysqli_error() . "<p>With query:<br>$query"); while ($row = mysqli_fetch_array($result)) //need to format the date on this function $date = $row['date']; { //get NewsID echo "<div class=\"headline\"> <a href=\"news_article.php?news_article=$row[id]\">$row[title]</a> <span class=\"date_of_article\">".date("m.d.y","$date")."</p> <p>$row[content]</p> </div> "; } } Any help would be great
  17. Hi guys i would like to check if a variable has been set and to find out wether its a particular number and which then takes it to the write page. i have two numbers i would like to check for, 67 and 68. If its 68 go here else go 67. here is my function so far; function subLevels() { if ((isset($_GET['cat_id']) ) && (isset($_GET['sublvl_id'])) && (is_numeric($_GET['cat_id'])) && (is_numeric($_GET['sublvl_id'])) ) { //correctly accessed $cat_id=$_GET['cat_id']; $sublvl_id=$_GET['sublvl_id']; } else { $errors[] = 'You have accessed this page incorrectly.'; } global $dbc; $query ="SELECT * FROM SubCat1 WHERE CategoryID = $cat_id AND SubLevelID = $sublvl_id ORDER BY SubCatID"; $result = mysqli_query ($dbc, $query)or die(mysqli_error() . "<p>With query:<br>$query"); while ($row = mysqli_fetch_assoc($result)) { //need to format the date on this function //get NewsID echo "<li><a href=\"industrial.php?medical_product=$row[CategoryID]&sublvl_id=$row[subLevelID]&subcat_id=$row[subCatID]\">$row[subCatName]</a></li>"; } } Any help would be grea!
  18. Hi Yesideez, I had all reporting errors on so it would display everything stupid thing that i might do.. I didnt want to surpress the notice, because if the function didnt work it wont harm how the site works but it would show a page without a title and i ideally want a title for each page. Thanks for your help
  19. Hi Ken, Sorted it out now, i placed the else statement within the switch...so it wasnt reading it write (if that makes any sense to you :S) This is the finished working code else{ if(isset($_GET['action'])) { switch($_GET['action']) { case 'about': echo ' - about us'; break; case 'news': echo ' - read all the latest news and our press release'; break; case 'contact': echo ' - make an enquiry'; break; case 'quality': echo ' - quality'; break; case 'home': echo ' - Temperature Triggered Color Changing Technology and Graphics'; break; case 'news headlines': echo 'news bulletins'; break; } } else{ echo 'nothing'; } } Again thanks for all your help
  20. Hi Ken, I followed your advice and replaced : after each ; so now my code looks like this }else{ if(isset($_GET['action'])) { switch($_GET['action']) { case 'about': echo ' - about us'; break; case 'news': echo ' - read all the latest news and our press release'; break; case 'contact': echo ' - make an enquiry'; break; case 'quality': echo ' - quality'; break; case 'home': echo ' - Temperature Triggered Color Changing Technology and Graphics'; break; case 'news headlines': echo 'news bulletins'; break; default: echo 'home page'; } } } Thanks Darren so when to test it out, when to the homepage and it still gave me no title and an error message, undefined index action... I will go back to the books on this one Again thanks for everyones help on this
  21. Hi Mchl, I did try that but nothing happened Thanks for helping
  22. Hi guys and girls, Im using a switch statment to display certain text in the title tags. currently all my links, have an action variable to select which title to use on certain pages. contact_us.php?action=contact however i visited the home page to see if it uses the default statement and it doesnt here is the switch statement switch($_GET['action']) { case 'about'; echo ' - about us'; break; case 'news'; echo ' - read all the latest news and our press release'; break; case 'contact'; echo ' - make an enquiry'; break; case 'quality'; echo ' - quality'; break; case 'home'; echo ' - more'; break; case 'news headlines'; echo 'news bulletins'; break; default; echo 'nothing'; } Reading the error php displays it says i have an undefined index, the line it shows is; switch($_GET['action']) here is the whole function if it helps function pageTitle() { if ((isset($_GET['medical_product'])) && (isset($_GET['subcat_id'])) && (is_numeric($_GET['medical_product'])) && (is_numeric($_GET['subcat_id']))) { //correctly accessed $medical_product=$_GET['medical_product']; $subcat_id=$_GET['subcat_id']; global $dbc; $query="SELECT * FROM SubCat1 WHERE CategoryID = $medical_product AND SubCatID = $subcat_id"; $result = mysqli_query ($dbc, $query)or die(mysqli_error() . "<p>With query:<br>$query"); while ($row = mysqli_fetch_array($result)) { echo "$row[subCatName]"; } } else { switch($_GET['action']) { case 'about'; echo 'LCR/Hallcrest - about us'; break; case 'news'; echo 'LCR/Hallcrest - read all the latest news and our press release'; break; case 'contact'; echo 'LCR/Hallcrest - make an enquiry'; break; case 'quality'; echo 'LCR/Hallcrest - quality'; break; case 'home'; echo 'LCR/Hallcrest - Temperature Triggered Color Changing Technology and Graphics'; break; case 'news headlines'; echo 'news bulletins'; break; default; echo 'nothing'; } } } Thanks, Darren
  23. lol, i tried that but left the "" instead, so it looked like this, '.str_replace('$dirty', '$clean', $row['SubCatName']).' thanks for pointing that out.
  24. Hello I am trying to replace two html characters from my string one and one ® with white space and the other no white space. ie. from fast cars.gif to fast cars.gif and from porsche®.gif to porsche.gif is it possible? Here us what i have go so far; $no_reg= ''; $dirty = array(' ','®' ); $clean = array (' ', ''); echo '<h5><img src="headerbars/'.str_replace(' ', ' ',$row['SubCatName']).'.gif" title="" alt="" style="position:absolute;top:12em;left:19em;border:none;"/></h5>'; I tried to set up two arrays, one with the problem and the other with the solution, but i am getting stuck. any pointers woud be great
×
×
  • 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.