505 Posted Topics
Re: You could add something simple like this following after increasing the health value. $health = min($health, 100); | |
Re: That should be simple enough if all you want to do is charge an additional day if the customer doesn't return the vehicle on or before the time they collected the vehicle. <?php date_default_timezone_set('Europe/London'); define('SECONDS_IN_DAY', 86400); define('DAYS_IN_MONTH', 30); define('DAYS_IN_WEEK', 7); define('COST_PER_MONTH', 52500); define('COST_PER_WEEK', 15000); define('COST_PER_DAY', 2500); $start_date = '2012-06-01 06:00:00'; … | |
Re: Thats because a . in CSS refers to a class, not an id. /** Id syntax */ #bold2 {margin-left:50px;} /** Class syntax */ .bold2 {margin-left:50px;} | |
Re: `strcasecmp('Hello', 'HELLO') == 0` - when strings are identical, regardless of case | |
| |
Re: Yes, you're correct that line 2 is important. That's checking the email field to determine whether the form, or at least an email addres has been submitted. You could modify your code to the following: <?php if (isset($_POST['comment']) && $_POST['comment']) { $ToEmail = 'youremail@site.com'; $EmailSubject = 'Site contact form'; $mailheader … | |
Re: It looks like most of the errors are caused by the fact that your `connect.php` script cannot be found and included, hence your database queries, etc are failing. It looks like you're in the news subdirectory. Is your connect script in the same directory, one above or elsewhere? Fix that, … | |
Re: You're calling the `diff` function on a non object. Lines 10 and 11 should read: $datetime1 = new DateTime($date1); $datetime2 = new DateTime($date2); | |
Re: There was a similar post topic quite recently, just with BB syntax instead. Try: function highlight($string, $term) { return preg_replace("/(?<!\<)(\b{$term}\b)(?!\>)/i", '<span style="color:#f00;">\\1</span>', $string); } | |
Re: You're calling a variable `$firstname` on line 66 of your file index.php and it hasn't been declared before use. Without seeing further code, it's difficult to advise further. | |
Re: Check your tags on line 207. IE doesn't handle malformed HTML very well. | |
Re: At a guess, I would think it has to do with the data type. In your first example, you're using simple variables, floats, ints, etc. In the second, you're using arrays, which in JavaScript are objects. Therefore, when assigning a variable to `var a`, you're actually just passing it a … | |
Re: I've not encountered the `get_header` action before. Should this not be `wp_head`? I've also not used the `wp_localize_script` function either. When using ajax functionality in WP admin, I too have used the `wp_ajax_<your action name>` action, which to call needs to correspond to the action called on the ajax-admin.php URL. … | |
Re: When I used to use Zend, it didn't have built in support for handing XLS files, so I used to use the [PHP Excel](http://phpexcel.codeplex.com/) library. Beware - It can be a little heavy on the memory, if handling very large XLS files (10,000 lines). | |
Re: To get the featured image, you can use the following code: <?php if(has_post_thumbnail()): ?> <div class="image"> <?php the_post_thumbnail(); ?> </div> <?php endif; ?> | |
Re: It rather depends what you're looking to do - doesn't it. | |
Re: On line 122 above, you're overwriting the total with every iteration of your loop. Create a preset variable `$total = 0` on line 103, and then replace line 122 with `$total += $subtotal;` | |
Re: Can you post your HTML form code? After submitting your form, are you getting any errors? Which form message are you seeing - the one on line 31 or 33? R. | |
Re: Have you tried looking [here](http://letmegooglethat.com/?q=mvc+design+pattern+benefits) yet? | |
Re: I don't see that your query is correct. The subquery you have used in the NOT IN statement uses the *u* alias, which isn't defined within the subquery itself. Likewise, the user collection table doesn't join the user item table, which is defined as using the *u* alias. Have you … ![]() | |
Re: Apparently you need to use negative assetions, as [described here](http://stackoverflow.com/questions/6056472/regex-to-match-keyword-if-not-enclosed-by-curly-braces) So, for your case, where you don't want the text matched if it's between square brackets, you would use: (?!\[)(\bsome title\b)(?!\]) function highlight($string, $term) { return preg_replace("/(?!\[)(\b{$term}\b)(?!\])/i", '<span style="color:#f00;">\${1}</span>', $string); } R | |
Re: I'm not sure that I fully understand why you feel that you need to use dynamic variable names. Have you tried something like: <input name="tableId[]" type="checkbox" value="<?php echo $row['ID']" /> This will allow you to select multiple checkboxes, and when submitted, they will all be contained within the variable tableId. … | |
Re: How about something simple like: echo str_repeat('Hello World ', 100); R. | |
Re: If you need to access and manipulate the tld data, a more appropriate solution would be to create a tld table, and instead store a foreign key to the correct tld in your domains table. | |
Re: I am a little confused. If you want a random integer, why would you want to increment / decrement it by one to select the next track? Surely, you'd want another random track? Anyway, you could: $result = mysql_query('SELECT COUNT(*) AS `count` FROM songlist'); $count = mysql_fetch_assoc($result); // Find random, … | |
Re: Depending on what you're trying to accomplish with the value you pass to PHP, you could try using the [jQuery Post](http://api.jquery.com/jQuery.post/) function. $(function() { $('#myTable td').click(function(event) { var value = $(this).closest('tr').find('.name').html(); $.post('test.php', {value: value}, function(response) { alert(response); }); ); }); <?php // test.php $value = isset($_POST['value']) ? $_POST['value'] : null; … | |
Re: You haven't explained what you're trying to do, so I have assumed that you want to insert a comma separated lsit of days into your database field. The reason only the last day is being saved is because you're overwriting the values in your loop on line 18. Instead, why … | |
Re: Can you provide examples of the URL structure you would like, and what you need that URL rewritten back to? | |
Re: Make it a .PHP file and just include headers to serve the content as XML. [CODE]header('content-type: text/xml');[/CODE] | |
Re: Store the song names in an array when fed from the form. E.g.: [CODE] <form method="post" action=""> <!-- field labels and submit button excluded for simplicity --> <input type="text" name="song[]" /> <input type="text" name="song[]" /> <input type="text" name="song[]" /> <input type="text" name="song[]" /> <input type="text" name="song[]" /> <input type="text" name="song[]" … | |
Re: Two points to note: DOMDocument::saveXML() returns either an XML string, or false on failure. To test if an error occurred, try var dumping the result. E.g.: [CODE]var_dump($dom->saveXML());[/CODE] If this is boolean false, then you have an error. Otherwise, the method will have returned an XML string. As such, you cannot … | |
Re: Strange... I have just tried your second example and it is giving me 00:50. [CODE] date_default_timezone_set('UTC'); $difference = strtotime('20:00:00') - strtotime('19:10:00'); echo date('H:i', $difference); [/CODE] Have you tried adding a full date before the time to see if it makes any difference? [CODE] date_default_timezone_set('UTC'); $difference = strtotime('2012-01-01 20:00:00') - strtotime('2012-01-01 … | |
Re: Have you enabled comments for the post? This must be done when editing a single post. If the comment options are not visible when editing the post, select the screen options link from the top right of the page and tick comments. | |
Re: mysql_fetch_assoc will return an array indexed by the column values specified in the select part of your query, whereas mysql_fetch_array will return a numerically indexed array with values in the order specified in the select part of your query. | |
Re: Contact Form 7 and Gravity Forms are both good WP Form plugins. And getting more than one row on a single line can be accomplished with CSS if the plugin does not support that feature. | |
Re: To give you a large hint, look at the function [URL="http://php.net/manual/en/function.fgetcsv.php"]fgetcsv[/URL]. This page will also include a code example demonstrating how to use the function. The function reads in a CSV file one line at a time, and stores the data in a numerically indexed array, thus allowing you to … | |
Re: For the remove empty function, try using the array_filter method. It removes zero and null values. | |
Re: Wrap the loop in a function. E.g. [CODE] function is_date_between($date, $dates_from, $dates_to) { $count = max(count($dates_from), count($dates_to)); for($i = 0; $i < $count; $i++) { $date_from = isset($dates_from[$i]) ? $dates_from[$i] : false; $date_to = isset($dates_to[$i]) ? $dates_to[$i] : false; if($date >= $date_from && $date <= $date_to) return true; } return … | |
Re: @pritaeas - unset requires you knowing the array index, which I'm guessing the OP will not know. Another option would be to change the way you're storing items in the session to the following: [CODE] $_SESSION['product_id'] = array( // Product id => Quantity 1 => 1, 2 => 3, ); … | |
Re: It looks like you're using WordPress. If so, can you not just use the built in [URL="http://codex.wordpress.org/Function_Reference/paginate_links"]pagination functionality[/URL]? [CODE] <?php global $wp_query; ?> <?php if($wp_query->max_num_pages > 1): ?> <footer> <p class="pagination"> Pages: <?php $big = 999999999; // need an unlikely integer $pagination = paginate_links(array( 'base' => str_replace($big, '%#%', get_pagenum_link($big)), 'format' … | |
Re: Try: [CODE] function func_name($date = null) { if(is_null($date)) $date = date('Y-m-d'); // Your code here } [/CODE] | |
Re: Have you checked your file permissions? The file needs to be writable by the server. chown apache businessinfo.txt chmod 644 businessinfo.txt R. | |
Re: If your website is installed in [url]http://localhost/mvc[/url], you need to set the rewrite base: [CODE] RewriteEngine On RewriteBase /mvc/ [/CODE] | |
Re: I'm not sure whether you've already set the values of $date and $time... [CODE] if(isset($_POST['want2book']) && $_POST['want2book'] == 'Yes') { if(! strlen(trim($_POST['date'])) || ! strlen(trim($_POST['time']))) { header("Location: {$errorurl}"); exit(0); } } [/CODE] | |
Re: Or try using HTML map and area tags, with each area containing a link to the page with the seat information. It might however be quite time consuming to add all of the areas. | |
Re: Where is $query set? The line above is executing the query, without capturing the result. Looks like it should be replaced with: [CODE] $query = " UPDATE Liberty SET firstname='$FName' , lastname='$LName' , PatientPhone='$PatientPhone' , FacName='$FacName' , FacAddress='$FacAddress' , PatRoom='$PatRoom' , FacCity='$FacCity' , FacState='$FacState' , FacZip='$FacZip' , FacPhone='$FacPhone' , CaregiverName='$CaregiverName' … | |
Re: I don't mean to be rude, but that code is a mess. 7000 lines in a single file? No wonder you're having issues. Anyhow, that doesn't help you. The issue could be further up the file, seeing as you have nested if/else statements, etc so I would suggest you use … | |
Re: If you're not even going to display the photographs on the website, save yourself the time and hassle of learning to develop a website and then actually building one, and just use a cloud storage provider - e.g. - Dropbox - Live Drive - iCloud - etc... | |
Re: I think your problem needs to be split into two parts. First, finding the letter(s). Second, finding the position. [CODE] $string = '0001564AC587B4965B5'; $positions = array(); // Find all letters preg_match_all('/[a-z]/i', $string, $matches); // Check if any letters found if(isset($matches[0])) { $offset = 0; // Iterate through each letter and … |
The End.