QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
This is weird. Url parameter and & symbol issue.
QuickOldCar replied to man5's topic in PHP Coding Help
Yes it should be urlencoded -
should be a double == when checking against something, a single when setting if (isset($_POST['name']) AND $_POST['name'] == "name"){ in your post form you set the value as abc, so it should be this if (isset($_POST['name']) AND $_POST['name'] == "abc"){
-
Your english seems fine. pagerank is mostly determined by backlinks from other websites seo is just optimizing your site and links to be better seen by search engines and keywords You can always make a front page and a sitemap of all your links Try phpmailer
-
You can create a new page in wordpress and name a folder the same, drop an index file within that and would work. The preferred way with maintaining your header,navigation and footer is to make a new custom page template in your theme. http://codex.wordpress.org/Page_Templates The basics: Create a new file in your current themes folder named what would like, lets call it custom.php Add the following code into custom.php <?php /* Template Name: Custom */ ?> <?php get_header(); ?> <style> <!-- div.custom { width: 80%; text-decoration: none; text-align:center; margin-top:0px; margin-bottom:0px; margin-right: auto; margin-left: auto; padding:0px; } --> </style> <?php echo "<div class='cusrom'>"; echo "custom code gets added this area"; echo "</div>"; ?> <?php get_footer(); ?> In the dashboard create a new page and name whatever you like, select the custom template located lower right area under Template, publish the new page You may also add the sidebar or anything else you desire.
-
That filter returns a true/false, the usage would be something like these examples <?php $vaildemail = "me@mail.com"; //example 1 $filterEmail = (filter_var($vaildemail, FILTER_VALIDATE_EMAIL)); if ($filterEmail == FALSE) { echo "not valid 1 <br />"; } else { echo "valid 1 <br />"; } //example 2 if (!filter_var($vaildemail, FILTER_VALIDATE_EMAIL)) { echo "not valid 2"; } else { echo "valid 2"; } ?>
-
I have 1,573 posts here that are only constructive, you are the only one I have ever seen in all my years here that used profanity in code surely is a TOS rule here for that, and most likely for name calling
-
How about not using curses in your code here.
-
Check to see that the $_POST value is set and not blank first if(isset($_POST['var1']) && trim($_POST['var1']) != ''){ $var1 = str_replace(array('%','_'),'',$_POST['var1']); } But also after you check for $var1 existing, you try and use it in your exit message so don't use it if (!$var1){ exit('Invalid form value'); }
-
http://book.cakephp.org/2.0/en/getting-started/cakephp-folder-structure.html lib for functions or classes you make yourself vendor for 3rd party plugin for cakephp framework only
-
http://www.topcoder.com/
-
You need to pass the $_POST value to your function and then to your query public function GetPageurlByPagecontent($term) { $db = Database::getDB(); $query = "SELECT * FROM searchengine where pageurl Like '$term'"; $searchengine =$db->query($query); return $searchengine; } if(isset($_POST['term']) && trim($_POST['term']) != ''){ $term = trim($_POST['term']); } else { $term = "something"; } Is there more code to it than this?, surely it wouldn't make a query as is. Is the dropdown select supposed to be a limit on how many results to display? If so also pass that value into the function and query and add LIMIT https://dev.mysql.com/doc/refman/5.7/en/select.html [LIMIT {[offset,] row_count | row_count OFFSET offset}] There is a pagination tutorial here at phpfreaks that would be much better to use. http://www.phpfreaks.com/tutorial/basic-pagination In my opinion you should get pagination working first and can insert search terms into it Instead of LIKE, you can do a fulltext search which would bring better results and simplify multiple keyword terms https://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html
-
Something more useful would be javascript,jquery,ajax,css,etc than learning a framework. Zend or Symphony if want to get into using frameworks. As for which IDE, is a pinned thread this section http://forums.phpfreaks.com/topic/182040-which-php-editor-do-you-think-is-the-best-v2/
-
Going by what you asked, this can do what you need. $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $last_path = end(explode("/", rtrim($url, "/"))); if (!is_int($last_path) && $last_path < 1) { $last_path = 1; } switch ($last_path) { case 1: echo "Number one"; break; case 2: echo "Number two"; break; case 3: echo "Number three"; break; case 4: echo "Number four"; break; } Did you consider using GET requests in your urls? http://xxxxx.dk/foo/foo/?page=4 if(isset($_GET['page']) && trim($_GET['page']) != '' && ctype_digit($_GET['page']) && $_GET['page'] >= 1){ $page = trim($_GET['page']); } else { $page = 1; } echo $page;
-
Simply put, an array should exist before you try to access it <?php ####################################################################################### # # SPOTTER NETWORK STORM REPORTS # version 1.00 # # This program is free and no license is required. # # # mesquiteweather.net # ####################################################################################### //// SETTINGS //// //// SETTINGS //// $bkgColor = '#d4d4d4'; // Background color Examples: "gray" "#CCC" "#CCCCCC" $bc = '#EEEEEE'; // Background color of table cells $dtColor = '#FFF'; // Date & time color Examples: "#FC0" "#FFCC00" "white" $width = '100%'; // Set the width of the report tables //// END OF SETTINGS //// ####################################################################################### ini_set('display_errors','1'); ## Start Configurable data ## //Set path to data file $data = "http://www.spotternetwork.org/data.php"; ## End Configurable data ## // overrides from the Carter Lake Settings.php file (if applicable) global $SITE; if(isset($SITE['cacheFileDir'])) {$cacheFileDir = $SITE['cacheFileDir']; } if (isset($SITE['imagesDir'])) {$imagesDir = $SITE['imagesDir'];} if(isset ($SITE['tz'])) {$ourTZ = $SITE['tz'];} if(!function_exists('date_default_timezone_set')) { putenv("TZ=" . $ourTZ); } else { date_default_timezone_set("$ourTZ"); } // get path info & protect for cross-site scripting vulnerability $sri = ($_SERVER['REQUEST_URI']) ? str_replace('#SA', '', htmlspecialchars(strip_tags($_SERVER['REQUEST_URI']))) : ''; // set borders $bbrdr = 'border-bottom:thin solid black'; // bottom $lbrdr = 'border-left:thin solid black'; // left $rbrdr = 'border-right:thin solid black'; // right $tbrdr = 'border-top:thin solid black'; // top $sbrdr = 'border-right:thin solid black; '. 'border-left:thin solid black'; // side //Define table to display after each storm report $afterTable = "<table style='margin-bottom: 5px;' border='0' cellpadding='0' cellspacing='0' width='100%'><tbody><tr><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7'></td><td class='shadow-mid' width='100%'><img alt='' src='images/1pixel.gif' border='0' height='7' width='7'></td><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7'></td></tr><tbody></table>\n"; // Let's assign the table some styles $noMessageStyle = "width:{$width}; text-align:center; margin:0px auto; background-color:{$bkgColor};"; $td1Style = "{$tbrdr};{$sbrdr}; padding:2px 0px 2px 6px; background-image:url({$imagesDir}headerbgd2.gif); color:{$dtColor};"; $td2Style = "{$sbrdr}; padding:6px 0px 0px 6px;"; $td3Style = "{$sbrdr}; line-height:5px;"; $td4Style = "{$sbrdr}; {$bbrdr}; padding: 2px 6px 6px 6px;"; //Set message to display if there were not report $noStormMessage = "<table style='{$noMessageStyle}' cellpadding='0' cellspacing='0'>\n"; $noStormMessage .= "<tbody>\n"; $noStormMessage .= " <tr><td style='{$td1Style}'>LIVE STORM SPOTTER REPORTS</td></tr>\n"; $noStormMessage .= " <tr><td style='{$td4Style}'>There are currently no storm reports</td></tr>\n"; $noStormMessage .= "</tbody>\n"; $noStormMessage .= "</table>\n"; $noStormMessage .= $afterTable; $xml = simplexml_load_file($data); //Set initial output to false $tData = false; foreach($xml->report as $report) { $date = $report['stamp']; $time = strtotime($date.'UTC'); $dateInLocal = date("D g:i a", $time); $narrative = $report['narrative']; $loc = $report['city1']; $tz = $report['tz']; $stormType = 'Unknown'; $stormTypesAry = array( 'tornado' => 'Tornado', 'funnelcloud' => 'Funnel Cloud', 'wallcloud' => 'Wall Cloud', 'rotation' => 'Rotation', 'hail' => 'Hail', 'wind' => 'Wind', 'flood' => 'Flood', 'flashflood' => 'Flash Flood' ); foreach($report->attributes() as $typeKey => $id) { if($id == 1) { if(array_key_exists($typeKey, $stormTypesAry)) { $stormType = $stormTypesAry[$typeKey]; } break; } } $stormTypesAry['tornado'] = array('name' => 'Tornado', 'color' => 'rgba(255, 0, 0, 0.2)'); $stormTypesAry['funnelcloud'] = array('name' => 'Funnel Cloud', 'color' => 'rgba(255, 100, 0, 0.2)'); $stormTypesAry['wallcloud'] = array('name' => 'Wall Cloud', 'color' => 'rgba(255, 255, 0, 0.2)'); $stormTypesAry['rotation'] = array('name' => 'Rotation', 'color' => 'rgba(255, 228, 181, 0.2)'); $stormTypesAry['hail'] = array('name' => 'Hail', 'color' => 'rgba(160, 0, 255, 0.2)'); $stormTypesAry['wind'] = array('name' => 'Wind', 'color' => 'rgba(235, 235, 250, 1.0)'); $stormTypesAry['flood'] = array('name' => 'Flood', 'color' => 'rgba(0, 255, 0, 0.2)'); $stormTypesAry['flashflood'] = array('name' => 'Flash Flood', 'color' => 'rgba(0, 255, 50, 0.2)'); $stormTypesAry['Other'] = array('name' => 'Other', 'color' => 'rgba(0, 255, 50, 0.2)'); $reportColor = ''; // get the stormType and reportColor using the $typeKey $stormType = $stormTypesAry[$typeKey]['name']; $reportColor = $stormTypesAry[$typeKey]['color']; // this line takes the place of all the switch/case logic // Set table style $tableStyle = "width: 100%; margin:0px auto; background-color:{$bkgColor};"; $td1Style = "{$tbrdr};{$sbrdr}; padding:2px 0px 2px 6px; background-image:url({$imagesDir}headerbgd2.gif); color:{$dtColor};"; $td2Style = "{$sbrdr}; padding:6px 0px 0px 6px; background-color:{$reportColor};"; $td3Style = "{$sbrdr}; line-height:5px; background-color:{$reportColor};"; $td4Style = "{$sbrdr}; {$bbrdr}; padding: 2px 6px 6px 6px; background-color:{$reportColor};"; // construct data for table display $tData .= "<table style='{$tableStyle}' cellpadding='0' cellspacing='0'>\n"; $tData .= "<tbody>\n"; $tData .= " <tr><td style='{$td1Style}'><b>{$stormType}</b></td></tr>\n"; $tData .= " <tr>\n"; $tData .= " <td style='{$td2Style}'>Reported: <b>{$dateInLocal}</b> - </b>Location: <b>{$loc}</b></td>\n"; $tData .= " </tr>\n"; $tData .= " <tr><td style='{$td3Style}'> </td></tr>\n"; $tData .= " <tr><td style='{$td4Style}'>Description: <b>{$narrative}</b></td></tr>\n"; $tData .= "</tbody>\n"; $tData .= "</table>\n"; $tData .= $afterTable; } //If no storms were in the source, set no storm message if(!$tData) { $tData = $noStormMessage; } echo $tData; ?>
-
This one should work <?php echo <<<MYHTML <div class="list" onclick="" location.href="#"> <div class="serverListHover" style="width: 90%; float: right"> <div class="serverListHover" style="width: 25%; float: right"> <span style="font-size: 12px;">Ip Address Here</span> <div style="background:blue; height:4px"></div> </div> <div class="serverListHover" style="width: 75%; float: left"> <img class="listImage" src="http://www.news.balkanenergy.com/wp-content/uploads/2014/02/InEnerg14-460x90-EN.jpg" alt="Pulpit rock" width="460" height="60"> </div> </div> <div class="serverListHoverLeft"> <span class="rank" style="display:inline-block; vertical-align:middle">123</span> </div> </div> MYHTML; ?>
-
Wrap everything in double quotes and single quotes within. Or use heredoc <?php echo <<<"MYHTML" <div class=""list"" onclick=""location.href="#"""> <div class=""serverListHover"" style=""width: 90%; float: right""> <div class=""serverListHover"" style=""width: 25%; float: right""> <span style=""font-size: 12px;"">Ip Address Here</span> <div style=""background:blue; height:4px""></div> </div> <div class=""serverListHover"" style=""width: 75%; float: left""> <img class=""listImage"" src=""http://www.news.balkanenergy.com/wp-content/uploads/2014/02/InEnerg14-460x90-EN.jpg"" alt=""Pulpit rock"" width=""460"" height=""60""> </div> </div> <div class=""serverListHoverLeft""> <span class=""rank"" style=""display:inline-block; vertical-align:middle"">123</span> </div> </div> MYHTML; ?> Forgot to mention can escape in and out of php to hml as well <?php //some php code here ?> <div class=""list"" onclick=""location.href="#"""> <div class=""serverListHover"" style=""width: 90%; float: right""> <div class=""serverListHover"" style=""width: 25%; float: right""> <span style=""font-size: 12px;"">Ip Address Here</span> <div style=""background:blue; height:4px""></div> </div> <div class=""serverListHover"" style=""width: 75%; float: left""> <img class=""listImage"" src=""http://www.news.balkanenergy.com/wp-content/uploads/2014/02/InEnerg14-460x90-EN.jpg"" alt=""Pulpit rock"" width=""460"" height=""60""> </div> </div> <div class=""serverListHoverLeft""> <span class=""rank"" style=""display:inline-block; vertical-align:middle"">123</span> </div> </div> <?php //more php code ?>
-
CloudFlare IP Geolocation - elseif help
QuickOldCar replied to essypowers's topic in PHP Coding Help
Ok, you need to know how and when to escape in and out of php to html. http://www.php.net/manual/en/language.basic-syntax.phpmode.php If is within php you need to echo and properly wrap in quotes You can also just break out of php and then back in like so <?php $country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; $not_allowed = array("FR","UK","US"); if (in_array($country_code, $not_allowed)) { echo "Site Under Maintenance"; } else { ?> <html> <body> </body> </html> <?php } ?> -
CloudFlare IP Geolocation - elseif help
QuickOldCar replied to essypowers's topic in PHP Coding Help
No idea why that if/else doesn't work, try as mac_gyver suggested using a check in an array <?php $country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; $not_allowed = array("FR","UK","US"); if (in_array($country_code, $not_allowed)) { echo "Site Under Maintenance"; } else { //place your code this area to show it } ?> -
CloudFlare IP Geolocation - elseif help
QuickOldCar replied to essypowers's topic in PHP Coding Help
This should work fine <?php $country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; $message = "Site Under Maintenance"; if ($country_code == "FR") { echo $message; }elseif ($country_code == "UK") { echo $message; }elseif ($country_code == "US") { echo $message; }else { //place your code this area to show it } ?> -
http://www.retrovideogamer.co.uk/ Hey retro games, retro site, what's it matter?
-
Thanks, not sure how that happened.
-
scrape html then create db using regex to snag keywords
QuickOldCar replied to ryanlitwiller's topic in PHP Coding Help
Sometimes the best place to learn something is from the source itself http://www.php.net/manual/en/language.types.array.php I used preg_match because I was looking at a single item in the loop preg_match_all is useful when you want to find multiple instances of something and find all possible matches- 10 replies
-
- simple_html_dom
- file_get_html
-
(and 2 more)
Tagged with:
-
I just recently replied to this post http://forums.phpfreaks.com/topic/287248-scrape-html-then-create-db-using-regex-to-snag-keywords/ but the date is showing Posted Yesterday, 11:19 PM This post was done at 7:32 PM EST and shows Posted Today, 12:32 AM