jarvis
Members-
Posts
543 -
Joined
-
Last visited
Everything posted by jarvis
-
Sorry AMcHarg I can't seem to see your suggestion, it appears blank?
-
Sorry to trouble you again, the above gives the following message: Parse error: syntax error, unexpected T_VARIABLE The line it refers to is this one: if ($Banner_Image_$i !='') { I can't see why this would cause an issue though? Thanks
-
Thank you, that's so helpful!
-
Hi All, I must be missing a trick here. I'm using the following block of code to show navigation. It tests to see if a particular field is blank, if it is, it won't show the link. Rather than repeating the block of code and numbering each one, what would be the best way to check the field in a loop? Here's the code: <?php $Banner_Image = get_post_meta($post->ID, 'Banner_Image', true); ?> <?php if ($Banner_Image!='') : ?> <a href="javascript:goto('.item1')">1</a> <?php endif; ?> <?php $Banner_Image_2 = get_post_meta($post->ID, 'Banner_Image_2', true); ?> <?php if ($Banner_Image_2!='') : ?> <a href="javascript:goto('.item2')">2</a> <?php endif; ?> <?php $Banner_Image_3 = get_post_meta($post->ID, 'Banner_Image_3', true); ?> <?php if ($Banner_Image_3!='') : ?> <a href="javascript:goto('.item3')">3</a> <?php endif; ?> <?php $Banner_Image_4 = get_post_meta($post->ID, 'Banner_Image_4', true); ?> <?php if ($Banner_Image_4!='') : ?> <a href="javascript:goto('.item4')">4</a> <?php endif; ?> <?php $Banner_Image_5 = get_post_meta($post->ID, 'Banner_Image_5', true); ?> <?php if ($Banner_Image_5!='') : ?> <a href="javascript:goto('.item5')">5</a> <?php endif; ?> Thanks
-
I've tried the above code. Although it doesn't show the error page, it now seems like the form doesn't submit at all or show any validation errors if you just click the submit button. I simply replaced the existing filter code with the above, I assume that was right? Thanks
-
Hi requinix Sorry by broke it means if you try and submit the enquiry form, it would simply go to page cannot be found, it didn't even check to validate the form. Is your suggested code to replace this: <?php /*Code filters out unwanted variables from $_REQUEST and $_SERVER['QUERY_STRING'] so they don't interfer with automatic searching functions*/ $filtered=array(); $filtered_query=""; //Filter foreach($_REQUEST as $key=>$value){ switch($key){ //keys to filter out case "utm_medium": case "utm_source": case "utm_content": case "utm_campaign": continue; break; default: Thanks again
-
Hi, Hope some one can help. We've a CMS which has the following code: <?php header('Content-type: text/html; charset=utf-8'); ?> <?php require_once "E:/domains/a/domain.com/user/htdocs/cms/lib/viewer_functions.php"; ?> <?php /*Code filters out unwanted variables from $_REQUEST and $_SERVER['QUERY_STRING'] so they don't interfer with automatic searching functions*/ $filtered=array(); $filtered_query=""; //Filter foreach($_REQUEST as $key=>$value){ switch($key){ //keys to filter out case "utm_medium": case "utm_source": case "utm_content": case "utm_campaign": continue; break; default: $filtered[$key]=$value; $filtered_query.=$key."=".$value."&"; break; } } $temp = $_REQUEST; //store $_REQUEST in a temporary variable $temp_query = $_SERVER['QUERY_STRING']; //set variables to filtered state $_REQUEST=$filtered; $_SERVER['QUERY_STRING']=$filtered_query; /* **getRecords function must come AFTER this line** */ ?> <?php list($home_pageRecords, $home_pageMetaData) = getRecords(array( 'tableName' => 'home_page', 'where' => whereRecordNumberInUrl(1), 'limit' => '1', 'allowSearch' => '0', )); $home_pageRecord = @$home_pageRecords[0]; // get first record ?> On the same page is an include to an enquiry form, the code for this is as follows: // process form if (@$_REQUEST['submitForm']) { // error checking $errorsAndAlerts = ""; $check = $_REQUEST['check']; $randomNumber = $_REQUEST['randomNumber']; if (!@$_REQUEST['name']) { $errorsAndAlerts = "Please add your name\n"; } if (!@$_REQUEST['email']) { $errorsAndAlerts = "Please add your email\n"; } else if(!isValidEmail(@$_REQUEST['email'])) { $errorsAndAlerts = "That email address is not valid\n"; } if (!@$_REQUEST['enquiry']) { $errorsAndAlerts = "Please add your enquiry\n"; } if (!@$_REQUEST['randomNumber']) { $errorsAndAlerts = "Please verify the number\n"; } $textToConvert = $_REQUEST['enquiry']; $convertedText = iconv("UTF-8", "ISO-8859-1", $textToConvert); // send email user if ((!$errorsAndAlerts) && ($randomNumber == $check)) { $to = "[email protected]"; $subject = "Quick Contact"; $email = "[email protected]"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: $email \r\n"; $body = "<strong>Full name</strong>: ". $_REQUEST['name'] ."<br />"; $body .= "<strong>Email</strong>: ".$_REQUEST['email'] ."<br />"; $body .= "<strong>Enquiry</strong>: $convertedText<br /><br />"; $body .= "The user who sent this message had the IP address <strong>".$_SERVER['REMOTE_ADDR']."</strong><br />"; $message = $body; // send message $mailResult = @mail($to, $subject, $message, $headers); if (!$mailResult) { die("Mail Error: $php_errormsg"); } redirectBrowserToURL("http://www.domain.com/thanks.php"); #$errorsAndAlerts = "Thanks! We've sent your email."; $_REQUEST = array(); // clear form values } } Problem is, the code which checks & filters for Google Analytics: <?php /*Code filters out unwanted variables from $_REQUEST and $_SERVER['QUERY_STRING'] so they don't interfer with automatic searching functions*/ $filtered=array(); $filtered_query=""; //Filter foreach($_REQUEST as $key=>$value){ switch($key){ //keys to filter out case "utm_medium": case "utm_source": case "utm_content": case "utm_campaign": continue; break; default: $filtered[$key]=$value; $filtered_query.=$key."=".$value."&"; break; } } $temp = $_REQUEST; //store $_REQUEST in a temporary variable $temp_query = $_SERVER['QUERY_STRING']; //set variables to filtered state $_REQUEST=$filtered; $_SERVER['QUERY_STRING']=$filtered_query; /* **getRecords function must come AFTER this line** */ ?> Seems to break the enquiry form. I'm guessing it's due to the $_REQUEST part of it. We need the filter in place because the CMS can't find a record if the URL has the UTM tagged on, filtering this out sorted the issue. Problem is, its now broken the enquiry form. Is there anything I can do to resolve this? TIA jarvis
-
Split content into 2 columns with the start of a para
jarvis replied to jarvis's topic in PHP Coding Help
Thanks guys. @MrAdam where do I place the regex part in my code? I think I can sort of see how to use it but not quite sure - sorry ;-/ -
Hi All, I hope someone can help. I use the below code to split content into 2 columns. Works a treat by finding the middle count of words and splitting. Problem is, sometimes it leaves the start of a line in one column and the rest in the other column. How can I alter the below to do what it does but find the start of a para as well to make it a neater split? God I hope that makes sense! Here's the code <?php $extract = str_replace("\r", "<br />", get_the_content('')); function splitMyText($colcontent, $columns) { $bodytext = array("$colcontent"); $text = implode(",", $bodytext); //prepare bodytext $length = strlen($text); //determine the length of the text $length = ceil($length/$columns); //divide length by number of columns $words = explode(" ",$text); // prepare text for word count and split the body into columns $c = count($words); $l = 0; for ($i=1;$i<=$columns;$i++) { $new_string = ""; $coloutput .= '<div class="column">'; for ($g=$l;$g<=$c;$g++) { if (strlen($new_string) <= $length || $i == $columns) $new_string.=$words[$g]." "; else { $l = $g; break; } } $coloutput .= $new_string; $coloutput .= "</div>"; } return $coloutput; } $columns = 2; echo splitMyText($extract, $columns); ?> Thanks
-
D'oh! Thanks that's worked a treat!!
-
Hi, If the cart total is less than 85 - too little If its between 85 - 100 - difference Above 100 - over a ton Thanks for looking
-
Hi, I can't see for looking on quite simply a very easy statement; $cartTotal = '900'; echo 'cart total '.$cartTotal.'<br/>'; $postage = '100'; echo 'Postage '.$postage.'<br/>'; $postThreshold = '85'; echo 'Post Threshold '.$postThreshold.'<br/>'; if ($cartTotal <= $postThreshold) { echo 'too little'; } elseif (($cartTotal >= $postThreshold) || ($cartTotal <= $postage)) { echo 'difference'; } else { echo 'over a ton'; } It works apart from if the cart total is above 100. What have I missed? Thanks
-
At mikosiko. No that's fine. It was one of those couldn't see for looking. Like how many f's in this sentence: That code worked like a charm & I'm incredibly thankful. Everyday is a learning curve, some more than others & each day I learn more tricks & tips to try before pestering the forums. Thanks again p.s There are 6
-
Hi Mikosiko, Thanks for the reply. I tried running your code direct in phpmyadmin as a sql query. The error it gave back I displayed but edited out the table database name. I ran the query exactly as you had it I assure you. Apologies as never meant to cause offence, just posting my results/findings :-(
-
Thanks mikosiko, unfortunately, that gives the following error: Table 'xxx.wb_bp_groups_members' doesn't exist
-
Hmmm, seems to only return 1 result. Will give this one some more thought - damn thing!
-
Oooooh that seems to be getting somewhere. I now get: name | value aerosols | joe bloggs null | [email protected] null | 123456 Oddly only shows one category? And the values list down. Changing the query to: That sorts the list values. Will give that some more testing. I think it's only returning one person and one category. However, I've several test people assigned to several cats. Will test more!! Thanks
-
Sorry, lol, got this one: SELECT command denied to user 'xxx'@'localhost' for table 'name' :-(
-
Actually, that was my error, I noticed there wasn't a space, having corrected it, it shows the same as the above I had: Aerosols John
-
Thanks for the perservering! I get this error: 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 'wp_bp_groups_members.id = wp_bp_xprofile_data.id LIMIT 0, 30' at line 1 Was that what you were expecting?
-
Sadly not: 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 '[xxx].wp_bp_groups.id = [xxx].wp_xprofile_data.user_id) ' at line 1 Good thought though! :-)
-
No sadly not. The db structure is in place and is from a 3rd party. Sadly I can't do anything with the structure or naming conventions - annoyingly!
-
I've tried this: Although it returns a result, it only returns a single result and not: Aerosols John Smith, [email protected], 123456 More like: Aerosols John
-
Thanks again, this time I get the error: Table 'xxx.wp_xprofile_data' doesn't exist Sorry!
-
Thanks Muddy_Funster unfortunately, that query doesn't work. It returns: SELECT command denied to user 'xxx'@'localhost' for table 'name'