Jump to content

webguy262

Members
  • Posts

    95
  • Joined

  • Last visited

Everything posted by webguy262

  1. also on the wish list, after the redirect, the browser should display the original requested url
  2. I've got this in the htaccess... redirect 301 /newsite/oldfile.html http://newwebdesign.com/newsite/new.php ... and it is working. The new.php file will dynamically create the content I want IF i can access the URL of the file requested BEFORE the redirect. That is, I need to access 'oldfile' from new.php. Can that be done?
  3. Thanks for the response... The sitemap for the site will have links to ~200 landing pages that should ideally have url's ending in html. Rather than have to create ~200 distinct pages, I thought it might be possible to have all the xxx.html url's call the same php page, and dynamically serve up the various pages, with titles, keywords, alt tags, content, etc. programmed to reflect the url requested. I want to do this with pages that load as html pages, tho, not php pages with get's in the url. Thoughts?
  4. Working on a site with a couple hundred virtually identical landing pages to maximize SEO. Rather than hard code the pages, I am wondering if there is a way to have one page that handles all the url's and dynamically codes and loads with title, keywords, content & alt tags all specific to the particular url requested. Seems like the challenge is doing it in a way that does not constitute a redirect. Is it better to do this in the .htaccess?
  5. this does not work for me... $category=mysql_real_escape_string($_GET['category']); if (is_int($category)) { i echo out $category and confirm it is an integer and yet the if statement does not fire what am i missing?
  6. That suggestion helped me find the problem... Another form in the project displays the imploded array as a comma delimited list. I added a space after the comma in the implode statement so I could just grab the string and output it as is. So when I ran the in_array, I was comparing strings with the extra space, against strings without the space. Thanks for your help!
  7. Thanks xyph... I'm almost there! The issue now is that only the first of several checked values comes back checked. Here's the current code... <?php // $session->userinfo['specialization'] is a database field. // echo $session->userinfo['specialization']; THIS WORKS AND OUTPUTS THREE VALUES AS "Automotive, Aerospace, Biotech/Life Sciences" $aSpecialization = array('Automotive', 'Aerospace', 'Biotech/Life Sciences', 'Chemicals', 'Damages Analysis', 'Electronics', 'Litigation', 'Manufacturing ', 'Materials', 'Medical Devices', 'Mobile Applications', 'Patent Prosecution', 'Physics', 'Renewable Energy', 'Semiconductors', 'Software', 'Telecommunications', 'Utilities'); //converting comma separated into array using explode function $dbspecialization= explode(',',$session->userinfo['specialization']); // echo $dbspecialization; THIS IS CONFIRMED AR AN ARRAY... OOUTPUTS 'Array' foreach ($aSpecialization as $specialization) { if(in_array($specialization,$dbspecialization)) { echo '<input name="specialization[]" type="checkbox" value="'.$specialization.'" CHECKED> '.$specialization.' <br />'; } else { echo '<input name="specialization[]" type="checkbox" value="'.$specialization.'"> '.$specialization.' <br />'; } } ?> So I'm still missing something.. Thoughts?
  8. Trying to get a form to display checked and unchecked values based on what is in the database. Hard coded form works fine. I implode the array and it goes into the database as a comma delimited string. But I need to let users edit the checkbox values, so I need to create the form by exploding the string, iterating through the array, and outputting the checkbox form elements. Here's what I have... <p>Specialization: <p> <?php //echo $session->userinfo['specialization']; THIS DISPLAYS THE STRING CORRECTLY $aSpecialization = array('Automotive', 'Aerospace', 'Biotech/Life Sciences', 'Chemicals', 'Damages Analysis', 'Electronics', 'Litigation', 'Manufacturing ', 'Materials', 'Medical Devices', 'Mobile Applications', 'Patent Prosecution', 'Physics', 'Renewable Energy', 'Semiconductors', 'Software', 'Telecommunications', 'Utilities'); //converting comma separated into array using explode function $dbspecialization= explode(',',$session->userinfo['specialization']); // echo $dbspecialization; THIS IS CONFIRMED AS AN array foreach ($aSpecialization as $specialization) { if(in_array($specialization,$dbspecialization)) { echo '<input name="specialization[]" type="checkbox" value="$specialization" CHECKED> $aSpecialization[] <br />'; } else { echo '<input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br />'; } } ?> But the output I get is... <input name="specialization[]" type="checkbox" value="$specialization" CHECKED> $aSpecialization[] <br /> <input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br /> <input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br /> etc... What am I missing?
  9. Trying to sort out setting a cookie that allows visitor to decide which sub domain to go directly to in subsequent visits. Somewhat complicated by the fact that the sub domains are running seprate instances of wordpress. Here's the code... any suggestions appreciated! <?php if (isset($_POST['submitted'])) { $site=$_POST['site']; setcookie("SitePref",$site, time() + 60*60*24*30, 'historybee.com'); if ($site == 'ms') { header("Location: http://ms.historybee.com/"); } elseif ($site == 'hs') { define('WP_USE_THEMES', true); require('./wp-blog-header.php'); } } else { //if we have a cookie, load the site if (isset($_COOKIE['SitePref'])) { if (($_COOKIE['SitePref']) == 'hs') { define('WP_USE_THEMES', true); require('./wp-blog-header.php'); } else { header("Location: http://ms.historybee.com/"); } } else { //if we don't have a cookie, load the form ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>The National History Bee</title> </head> <body style="margin:0;padding:0;background: url('http://ms.historybee.com/wp-content/themes/makinghistoryblue/img/body_bg_hb5.jpg') repeat-x scroll center top #F2BF3B;"> <div align="center" style="width:800px;margin:0 auto;background:#fff;"> <p><img src="http://ms.historybee.com/wp-content/themes/makinghistoryblue/img/nhb_logo.png"> <p><h1>Welcome to the National History Bee!</h1> <p>The National History Bee has both High School and Middle School competitions. <p>Please choose which site you would like to visit. Your choice will be remembered for 30 days. <form action= "<?php echo $_SERVER['PHP_SELF']; ?>" method ="POST"> <input type="radio" name="site" value="ms"> Middle School Competition <input type="radio" name="site" value="hs"> High School Competition <input type ="hidden" name="submitted" value="true"> <p><input type="submit" value="Remember My Choice"> </form> <br /><br /><br /> </div> </body> </html> <?php } } ?>
  10. you're right... the date never went into the dbase correctly.
  11. Gett an error from some custom code I inherited in a WordPress installation. Here is the error... Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (--) at position 0 (-): Unexpected character' in /home2/history8/public_html/bee/wp-content/themes/makinghistoryblue/beeteachers.php:27 Stack trace: #0 /home2/history8/public_html/bee/wp-content/themes/makinghistoryblue/beeteachers.php(27): DateTime->__construct('--') #1 /home2/history8/public_html/bee/wp-includes/plugin.php(395): bee_teachers('') #2 /home2/history8/public_html/bee/wp-admin/admin.php(151): do_action('bee_teachers', Array) #3 {main} thrown in /home2/history8/public_html/bee/wp-content/themes/makinghistoryblue/beeteachers.php on line 27 Here is the code... <?php $teachers = $wpdb->get_results("SELECT * FROM bee_teachers,bee_postmeta WHERE bee_teachers.statebee=bee_postmeta.post_id and meta_key='regional_date' ORDER BY meta_value ASC"); $today = new DateTime(); foreach ($teachers as $teacher): $site = get_post($teacher->statebee)->post_title; $date = new DateTime($teacher->meta_value); // this is line 27, mentioned in the error if($date<$today) $style=' style="color:#999"'; else $style=''; ?> If I remm out these lines, the query works, just no styling difference based upon date... $date = new DateTime($teacher->meta_value); // this is line 27, mentioned in the error if($date<$today) $style=' style="color:#999"'; else $style=''; Thoughts?
  12. In a LAMP environment at Media Temple, at least one pdf i'm hosting is hanging in IE (FF, Chrome, etc. work fine). In IE, the PDF partially downloads but then just hangs. It opens, but only to a certain page. Everything works fine if I host the file on a Win box. IE gets the whole thing. Any thoughts?
  13. Thanks to all. Now I just need to pore over all of it and try to learn what I don't understand!
  14. tried this... <?php error_reporting(E_ALL); include ('tempconv.class.php'); $temp = new Temperature(100); echo "In Fahrenheit: " . $temp->getTemp("f"); ?> ...but i don't get anything
  15. changed, but still nothing... <?php include ('tempconv.class.php'); $temp = new Temperature(100); echo "In Fahrenheit: " . $temp->getTemp("f"); ?> <?php class Temperature { private $temperature; public function __construct($value, $units = "c") { $units = strtolower($units); if ($units !== "c") { $val = $this->convertTemp($val, $units); } $this->temperature = $val; } public function getTemp($units = "c") { $units = strtolower($units); if ($units === "c") { return $this->temperature; } else { return $this->convertTemp($this->temperature, $units); } } public function setTemp($val, $units = "c") { $units = strtolower($units); if ($units === "c") { $this->temperature = $val; } else { $this->temperature = $this->convertTemp($val, $units); } } private function convertTemp($val, $units = "c"); { $units = strtolower($units); if ($units === "c") { return $val; } else ($units === "f") { return $this->convertToFahrenheit($val); } } private function convertToFahrenheit($val) { $this->val = ($this->val / 5) * 9 + 32; } } ?> Appreciate you hanging in with me on this!
  16. I am trying with this... <?php include ('tempconv.class.php'); $temp = new Temperature(100); echo "In Fahrenheit: " . $temp->getTemp("f"); ?> ...but I just get a blank page. What am I missing?
  17. OK, I think I'm starting to understand at least some of this... I don't need Kelvin, so I removed that. I put the formulas in, but not totally sure I did that right. Here's what I have at this point for the class: <?php class Temperature { private $temperature; public function __construct($value, $units = "c") { $units = strtolower($units); if ($units !== "c") { $val = $this->convertTemp($val, $units); } $this->temperature = $val; } public function getTemp($units = "c") { $units = strtolower($units); if ($units === "c") { return $this->temperature; } else { return $this->convertTemp($this->temperature, $units); } } public function setTemp($val, $units = "c") { $units = strtolower($units); if ($units === "c") { $this->temperature = $val; } else { $this->temperature = $this->convertTemp($val, $units); } } private function convertTemp($val, $units = "c"); { $units = strtolower($units); if ($units === "c") { return $val; } else ($units === "f") { return convertToFahrenheit($val); } } private function convertToFahrenheit($val) { $this->val = ($this->val / 5) * 9 + 32; } } ?> Am I close?
  18. Thanks for the input. I now have this for set/get... <?php private $tempC = null; private $tempF = null; public function getTempC(){ return $this->tempC; } public function setTempC($tempC){ $this->tempC = $tempC; } public function getTempF(){ return $this->tempF; } public function setTempF($tempF){ $this->tempF = $tempF; } ?> And this for the class and the formulas... <?php class Temp { public $tempC; public $tempF; function ConvertCF(){ $this->tempF = ($this->tempC / 5) * 9 + 32; return $this->tempF; } function ConvertFC(){ $this->tempC = ($this->tempF - 32) / 9 * 5; return $this->tempC; } } ?> But I still don't know how to bring these pieces together. A big part of my problem is I don't really understand the get/set declaration. Do I really need it?
  19. I'm trying to write a class with getters and setters that converts between centigrade and fahrenheit so that when one value is set, it updates the other value. I'm struggling to bring together the pieces I think I need. I've got this for the setters and getters... private $tempC = null; private $tempF = null; public function getTempC(){ return $this->tempC; } public function setTempC($tempC){ $this->tempC = $tempC; } public function getTempF(){ return $this->tempF; } public function setTempF($tempF){ $this->tempF = $tempF; } And this for the rest of the class (var's and functions)... <?php class Temp { var $TempC; var $TempF; function ConvertCF(){ $temp = ($TempC / 5) * 9 + 32; return $temp; } function ConvertFC(){ $temp = ($TempF - 32) / 9 * 5; return $temp; } } ?> But I (obvioulsy) need some direction!
  20. This did what I needed without a subselect... SELECT t1.user, MAX(t2.logindate) FROM t1 LEFT OUTER JOIN t2 l ON t1.user = t2.user GROUP BY user ORDER BY logindate DESC ...key was GROUP BY
  21. thanks, but i just figured it out!
  22. user is in table1, logindate is in table2, userid is common to both tables. need a query that returns the userid, user, and ONLY THE MOST RECENT logindate for each user. i know i need a subselect and a MAX(), but i can't get exactly what i need closest i've come is getting a single result: the userid, user and logindate for the user with the most recent lastlogin appreciate your help
  23. Thanks to all who replied. What I want is best captured by ... SELECT max(date),email FROM ... GROUP BY email It omits duplicate email address and give the latest date an email was entered. Thanks again for helping me learn!
  24. Well, the "select distinct email, date and group by email" works. Are you saying that "select email, date and group by email" would produce the same 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.