QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
I'm not making the plugin, maybe someone else will. You should ask the author.
-
Do you have a checked/unchecked value or equivalent in your database? This way can mark the checked ones. Taking a stab in the dark here... if($do['checked'] == true){ $checked = "checked='checked'"; }else{ $checked = ""; } echo "<input type='checkbox' name='staff[]' value='".$do['id']."' ".$checked." />"; If you want to pass all the staff regardless to checked or not can send a hidden value. echo "<input type='hidden' name='allstaff[]' value='".$do['id']."' />"; so on display would be $_POST['allstaff']
-
So now I will put this together as what your code is, be sure to break in and out of php to html properly or echo the entire form in php code: <?php echo "<form name='Form' action='posting.php' method='post'>"; while($do=mysql_fetch_array($sql){ echo $do['id'].": <input type='checkbox' name='staff[]' value='".$do['id']."' /><br />"; } echo "<input type='submit' name='checked' value=checking'><br />"; ?> posting.php <?php //display on posting.php if(isset($_POST['staff'])){ foreach($_POST['staff'] as $staff){ echo $staff."<br />"; } } ?>
-
The while loop is the loop. and correct, just display the value in the $_POST array instead of making each checkbox name a number, you can just make them an array and loop those <form name='Form' method='post'> <?php $dummy_array = range(1,20); foreach($dummy_array as $ids){ echo $ids.": <input type='checkbox' name='staff[]' value='".$ids."' /><br />"; } ?> <input type='submit' name='checked' value='submit'><br /> <?php //display if(isset($_POST['staff'])){ foreach($_POST['staff'] as $staff){ echo $staff."<br />"; } } ?>
-
Maybe this will help, i used a dummy range versus your while loop <form name='Form' method='post'> <?php $dummy_array = range(1, 20); $x = 1; foreach ($dummy_array as $ids) { echo $x . ": <input type='checkbox' name='" . $x . "' value='" . $ids . "' /><br />"; $x++; } ?> <input type='submit' name='checked' value='checking'><br /> <?php //display if (isset($_POST)) { foreach ($_POST as $key => $value) { echo $key . " - " . $value . "<br />"; } } ?>
-
Only put in the loop the parts of form need to add new values with php well you did not break out of php and back in, might as well echo in php <form name='Form' action='posting.php' method='post'> <?php if($x==""){ $x=1; } while($do=mysql_fetch_array($sql){ echo "<input type='checkbox' name='".$x."' value='".$do[id]."' />"; $x++; } ?> <input type='submit' name='checked' value='checking'>
-
Are donations to specific users okay?
QuickOldCar replied to Monkuar's topic in PHPFreaks.com Website Feedback
I thought it would be a cool idea to have a member to member donation. Members could buy credits from this website using whatever payment method. 1 credit equals one US dollar The credits can be given to other members easily by clicking a donation button under their name. Would want to have a waiting period before a member can cash in the credits due to cancelled paypal and such. -
Your snippet works for me. Missing file!
-
Help with displaying a successful hyperlink
QuickOldCar replied to Chrisj's topic in PHP Coding Help
Ouch, these are the people we are supposed to be helping the most, the ones that need it. -
Check if user entered text contains allowed domain values?
QuickOldCar replied to jacob21's topic in PHP Coding Help
This will check exact domains only, so if wanted the subdomains as well need to add them into $allowedDomains Since this is text and people do not always add a www. or a protocol like http:// or https://, I searched for decimal points instead. <?php //parse url function function parseTheUrl($url) { $new_parse_url = str_ireplace(array( "www.", "mms://", "rtsp://", "http://", "https://", "http://", "ftp://", "feed://" ), "", trim($url)); $parsedUrl = @parse_url("http://$new_parse_url"); return strtolower(trim($parsedUrl['host'] ? $parsedUrl['host'] : array_shift(explode('/', $parsedUrl['path'], 2)))); } //input text examples $inputText = "come visit my http://viagara.com website or come to pills.com"; //$inputText = "A normal message with no urls in it."; //$inputText = "This is testing http://www.youtube.com and also .google.com..... lets see what 5.27 does"; //alowed domains array $allowedDomains = array( "google.com", "youtube.com", "test.org" ); //remove multiple whitespace and trim $str = preg_replace('~\s+~', ' ', trim($inputText)); //explode all words by spaces $array = explode(" ", $str); //loop all the words foreach ($array as $value) { //replace multiple decimals with a single $value = preg_replace('~\.+~', '.', trim($value)); //remove decimal from beginning $value = ltrim($value, "."); //remove decimal from end $value = rtrim($value, "."); //check for any with a decimal within, most likely a url if (preg_match('~\.~', $value)) { //exclude numbers at end of expected domain if (ctype_alpha(end(explode(".", $value)))) { //create array with domains found in message $domains[] = parseTheUrl($value); //parsing them for better results and lowercases } } } //checking exact domain //if $domain array exists if ($domains) { //print_r($domains); //loop domains foreach ($domains as $domain) { //check if is not in allowedDomains if (!in_array($domain, $allowedDomains)) { $inputText = "Message not allowed"; //change inputText } } } //echo the message echo $inputText; ?> -
I looked through the mga_functions.php and mga_create_tier_commissions() function mga_create_tier_commissions($sale_id){ global $wpdb; // tiers $tier_commissions = mga_get_setting('tier_commissions'); $tier_levels = mga_get_setting('tier_levels'); // affiliate $affiliate = $wpdb->get_row("SELECT * FROM ".TBL_SALES." WHERE `id`='{$sale_id}'"); // parent $parent_affiliate_id = $wpdb->get_var("SELECT DISTINCT(`parent_affiliate_id`) FROM ".TBL_AFFILITE_TIERS." WHERE `affiliate_id`='{$affiliate->affiliate_id}'"); // loop $level=1; $sub_affiliates=array(); // loop while(intval($parent_affiliate_id)>0){ // next level $level++; // gather all subs $sub_affiliates[$level]=$parent_affiliate_id; // parent $parent_affiliate_id = $wpdb->get_var("SELECT `parent_affiliate_id` FROM ".TBL_AFFILITE_TIERS." WHERE `affiliate_id`='{$parent_affiliate_id}'"); // break if($level==($tier_levels)) break; } // set price if(count($sub_affiliates)>0){ $tier=2; foreach($sub_affiliates as $level=>$parent_affiliate_id){ $commission_amount=($tier_commissions[$tier]/100)*$affiliate->totalprice; $columns =array('affiliate_id' => $parent_affiliate_id, 'click_id' => $affiliate->click_id, 'purchaseid' => $affiliate->purchaseid , 'totalprice' => $affiliate->totalprice, 'commission_amount' => $commission_amount, 'sale_dt' => $affiliate->sale_dt, 'buyer_name' => $affiliate->buyer_name, 'buyer_email' => $affiliate->buyer_email, 'item_type' => 'sales' , 'item_id' => $affiliate->item_id, 'transaction_id' => $affiliate->transaction_id, 'pay_status' => $affiliate->pay_status); // insert $success=$wpdb->insert(TBL_SALES, $columns); $sale_id=$wpdb->insert_id; $tier++; // mail when processed if($affiliate->pay_status=='processed'){ // mail to affiliate mga_mail_notify_affiliate($sale_id); // mail to admin mga_mail_notify_admin($sale_id,'sale'); } } } } From what I see these 2 lines are the only thing stopping the function from doing more levels and tiers I assume this is a global plugins option $tier_levels = mga_get_setting('tier_levels'); then in the while loop if($level==($tier_levels)) break; What happens if comment out those 2 lines? Or make more tier_levels options globally with many additional functions to match. After that you still have all the checks looking for second_tier in wp_aff_award_second_tier_commission()
-
Help with understanding echo "</"; effects thereafter.
QuickOldCar replied to mprpjo's topic in PHP Coding Help
You should keep coding logic and html separate. -
array to string but hard return between words
QuickOldCar replied to kalster's topic in PHP Coding Help
Unless you mean something like this with multiple checkboxes <form method="POST" > one: <input type="checkbox" name="boards[]" value="one"/> two: <input type="checkbox" name="boards[]" value="two"/> three: <input type="checkbox" name="boards[]" value="three"/> <input type="submit" name="search" value="Search"/> </form> <?php if(isset($_POST['boards']) && trim($_POST['boards']) != ''){//check if is set and not empty $allboards = implode(",",$_POST['boards']); echo $allboards; } ?> -
array to string but hard return between words
QuickOldCar replied to kalster's topic in PHP Coding Help
Not sure why making that an array and back, this could work. if(isset($_POST['boards']) && trim($_POST['boards']) != ''){//check if is set and not empty $boards = trim($_POST['boards']);//trim end whitespace $boards = preg_replace('/\s+/', ' ',$boards);//remove multiple spaces $boards = str_replace(" ",",",$boards);//replace space with comma echo $boards; } -
Face Book share button on my php page selects wrong image
QuickOldCar replied to yasirmehmood123's topic in PHP Coding Help
If you don't cache your pages, then is facebook caching results. Is a debugger tool there. http://developers.facebook.com/tools/debug https://developers.facebook.com/docs/technical-guides/opengraph/defining-an-object/#update you can post to graph.facebook.com with 'scrape=true' and it will re-fetch the content -
mysql version 5.6+ supports fulltext boolean for innodb
-
Original Image Size, Thumbnail Image, Anchor Tag, Referencing?
QuickOldCar replied to glassfish's topic in PHP Coding Help
Append something like timestamp to the files name when saving it. If you want to store it as md5 after so be it, as long as you save what the image actually is in your database. $_SERVER['REQUEST_TIME'] will work It's supposed to display the sizes of the image are viewing. If you want to add additional info to original size...add it to alt or title, under the image on page, possibly even a js script like mouseover event. -
Face Book share button on my php page selects wrong image
QuickOldCar replied to yasirmehmood123's topic in PHP Coding Help
$selectedImage=$_GET['selectedImg']; // this param is passed from qry string whihc is sent by a previos page, I want to change this param every time parent page sends a request of new image. $ImageAddress='http://www.mySIte.com/'.$selectedImage; //creating URL of image , if i paste this URL in browser , image is fetched successfully. You query mysql with the page id or slug from your databse (something unique), then should be able to get all the info you need and populate the opengraph data. Don't rely on passing GET requests from previous pages or ones that could possibly be empty or wrong. -
So the same issue as this post http://forums.phpfreaks.com/topic/291271-wordpress-plugin-help TOPIC MERGED That's why I suggested a function to handle this better and not trying to duplicate mass amounts of code for additional tiers. If my function is not exactly what you need modify or make one that does work for you.
-
safe-mode and its effects on vhosts - why does turning off
QuickOldCar replied to Maze's topic in PHP Coding Help
the interesting thing: image upload is - sometimes possible and sometinmes impossible: Possibly not a safe mode issue, maybe file upload size limit,timeout or other. safe mode is deprecated version 5.30 and gone in 5.4+. Warning This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0. It was an attempt to make shared servers more secure, but didn't work so well and caused permission issues. It will make files belonging to the server that your scripts can't do anything with. The correct way is to set profiles in the operating system. Why not just turn it off? My suggestion is to compare your php.ini settings and make them match the one that works. Hosts should be updating php to somewhere near the latest php versions, if not then find a host that does. PHP is up to version 5.6.1 now, lots of changes and even missing out some new features. -
RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^info/([^/]+)/([^/]+)/([^/]+)/?$ info.php?country=$1&state=$2&city=$3 [L] RewriteRule ^info/([^/]+)/([^/]+)/?$ info.php?country=$1&state=$2 [L] RewriteRule ^info/([^/]+)/?$ info.php?country=$1 [L] That should work for a rewrite, but your check for $_GET is wrong if (isset($_GET["country"]) && trim( $_GET["country"]) != '') { echo $_GET["country"]."<br />"; } if (isset($_GET["state"]) && trim( $_GET["state"]) != '') { echo $_GET["state"]."<br />"; } if (isset($_GET["city"]) && trim( $_GET["city"]) != '') { echo $_GET["city"]."<br />"; } if wanted to check all 3 would need to do this if (isset($_GET["country"]) && isset($_GET["state"]) && isset($_GET["city"]) ) {
-
Newbie Need help build and test database or write php code
QuickOldCar replied to sorefingers00's topic in MySQL Help
Whatever works for you. phpmyadmin, write connection scripts with php or use some sort of program like workbench -
Database is not updating with new info
QuickOldCar replied to Thunder_Wolf's topic in PHP Coding Help
Maybe you didn't type your fixed code correctly. mysql_* functions and mysqli_* functions do not mix. You show the fixed as die('Could not enter data: ' . mysql_error($con)); -
You may want to use natsort() on the array if want the natural order for numbers. If are grouping 0-9 by first characters sort() is fine