505 Posted Topics
Re: If you want to store an object or array in a textual format, you should [URL="http://uk2.php.net/manual/en/function.serialize.php"]serialize[/URL] it before storing and [URL="http://uk2.php.net/manual/en/function.unserialize.php"]unserialize[/URL] it to reverse the process. It looks like what you have is an [URL="http://php.net/manual/en/function.var-export.php"]exported[/URL] array. I'm not aware of a way to import an array in that format, but … | |
Re: If you'd like access to MySQL, but don't want to use the command line, you could always install phpMyAdmin. If I recall correctly, it is available through Tasksel also. R. | |
Re: Have you tried Googling for your question? Here, [URL="http://lmgtfy.com/?q=redirect+www+to+without+www"]let me[/URL]. First result: [CODE]RewriteCond %{HTTP_HOST} ^www\.abc\.co.in$ [NC] RewriteRule ^(.*)$ http://abc.co.in/$1 [R=301,L][/CODE] | |
Re: I disagree. If the information is already in the public domain, e.g. in the Yellow Pages, then they have already consented to it being published. If you're talking about publishing someone's private information, then I would agree that approval is required first. If I were in doubt, I would assume … | |
Re: I wasn't aware you could use && in SQL queries (see line 14). Change it to AND instead. Also, you say you searched the forum; the first post in this forum (at the top of the page tackles the same issue), and [URL="http://www.daniweb.com/forums/search.php?searchid=17731347"]searching for the exact title of your post[/URL] … | |
Re: Can you post the code which validates and inserts the content into the database, and the code that retrieves and displays the content to the webpage? And I assume if the Chinese characters are displaying correctly in the database the tables and fields are using UTF-8 Unicode encoding, and the … ![]() | |
Re: [CODE=php] $words = 'Hello world hello world this is hello world'; $words = explode(' ', $words); $frequency = array(); foreach($words as $word) { $word = strtolower($word); if(isset($frequency[$word])) $frequency[$word] += 1; else $frequency[$word] = 1 } echo '<pre>'; print_r($words); echo '</pre>'; [/CODE] | |
Re: I would expect the issue to be that you do not have Apache and PHP configured correctly. [URL="http://www.linuxforums.org/forum/servers/31190-how-find-out-mod_php5-installed-working.html"]Have you installed mod_php properly[/URL]? | |
Re: Just use the mysql_affected_rows function. [CODE=php] mysql_connect('host', $username, $password); @mysql_select_db($database) or die('Unable to select database'); $query = "INSERT INTO new VALUES ('$first','$last','$phone','$mobile','$fax','$email','$web')"; mysql_query($query); if(1 === mysql_affected_rows()) echo 'insert passed'; else echo 'insert failed'; mysql_close(); [/CODE] | |
Re: You could always add all of the files to the include path, so that they're already loaded into memory. This is how a lot of frameworks operate. [CODE=php] set_include_path(implode(PATH_SEPARATOR, array( '/path/to/classes/directory', get_include_path(), )); [/CODE] | |
![]() | Re: I looked into using embedded fonts only last week. Using the @font-face declaration at the top of my stylesheet, the font displayed successfully in all major browsers, including IE6+. I abandoned the idea in the end, because the TTF file was rather large and substantially slowed the page loading. Still, … ![]() |
Re: Why not just work it out when querying the database? The following will check whether there is more than two minutes difference between the Date/Time value, `timed`, and the current time. If it is, the field `lapsed` will be set to 1. Otherwise it'll be 0. [CODE=php] $sql = "SELECT … | |
Re: Is your JavaScript function wrapped in: [CODE=javascript] $(function() { // code goes here... }); [/CODE] or [CODE=javascript] (function() { // code goes here... })(); [/CODE] | |
Re: I think you need to restructure your cart array: [CODE=php] <?php $_SESSION['cart'] = array(); // Add categories as keys, rather than values $category = 'Tops'; $_SESSION['cart'][$category][] = $productA; $category = 'Trousers'; $_SESSION['cart'][$category][] = $productB; // Loop through your cart foreach($cart as $category => $products): ?> <h2><?php echo $category; ?></h2> <?php … | |
Re: This is quite a basic tutorial to help you get started: [url]http://www.tizag.com/mysqlTutorial/mysqljoins.php[/url] | |
Re: I have found the [URL="http://phpexcel.codeplex.com/"]PHPExcel[/URL] library useful in the past. | |
Re: Make them float:left and float:right respectively, and display:inline, or add a fixed width if using display:block; | |
Re: This sounds like a HTML/CSS issue, rather than PHP. You might get a better response in the HTML/CSS forum. But as Twiss said, if you post your code, please can have a look. If you have a publicly accessible link, that could be helpful too. | |
Re: Try the [URL="http://php.net/manual/en/function.shell-exec.php"]shell_exec[/URL] function. But use it with caution. R. | |
Re: Regular expressions can be tough to understand. Taking the example you've posted, there are a couple of mistakes: [CODE=php] if(preg_match("/^[a-z\d'\.\-]{2,20}$/i", $_POST['username'])) { // ... } [/CODE] Looking at the expression, you'll see that I have enclosed it in double quotes rather than single. This is to avoid issues with the … | |
Re: From the gist of your post, it doesn't sound as though you know how to accomplish any part of your project whatsoever. Be that the case, are you not perhaps being overly ambitious? If I am wrong in my initial thoughts, perhaps you would care to outline what you have … | |
Re: Have you considered using a JavaScript framework, e.g. jQuery? Frameworks offer a lot of benefits, for one making AJAX requests far easier by handling cross browser compatibility issues, etc. Using jQuery, you could do the following: [CODE=php] <script type="text/javascript"> $(function() { $('div.clickable').click(function(event) { $.get('test.php', {id: $(this).attr('id')}, function(response) { $(this).text(response); //$(this).html(response); … ![]() | |
Re: If you store the session details in your database, together with a timestamp for when the session was last updated, you could use this together with a cron to delete old files as required. R. | |
Re: If you add a datetime and status field to your table, you could modify your script to only display offers with a status of active. At midnight, retrieve all the new offers as you are now, but instead of deleting the existing offers, insert these new offers alongside them, but … | |
Re: You could do something as simple as: [CODE=php] $date = date('Y-m-d', strtotime('3 days ago')); $sql = "SELECT * FROM `table` WHERE `date` >= '{$date}'"; // OR $date = date('Y-m-d', strtotime('7 days ago')); $sql = "SELECT * FROM `table` WHERE `date` >= '{$date}'"; [/CODE] R. | |
Re: When I've needed to do this in the past, I always Google for something like: "Object to XML PHP" or "Array to XML PHP". This search yielded the following results: [URL="http://www.sean-barton.co.uk/2009/03/turning-an-array-or-object-into-xml-using-php/"]http://www.sean-barton.co.uk/2009/03/turning-an-array-or-object-into-xml-using-php/[/URL] [URL="http://stackoverflow.com/questions/137021/php-object-as-xml-document"]http://stackoverflow.com/questions/137021/php-object-as-xml-document[/URL] | |
Re: I would use a combination of the two. You only need to see information about all of the themes when you want to choose the theme to use. If you therefore store the information about each theme within a file, the overhead to parse the files for this information will … | |
Re: We cannot help you unless you post the code and database tables you have written to achieve this so far. | |
Re: Hi, Create a table which stores the opening and closing time for each day of the week. Hence, if the store was open from 08:00 until 12:00 and then 13:00 until 18:00 on Monday through Friday, you could do: id day open close 1 Monday 08:00:00 12:00:00 2 Monday 13:00:00 … | |
Re: The [URL="http://uk2.php.net/manual/en/function.mysql-query.php"]mysql_query[/URL] function returns false in the event of an error - usually as a result of an error with your query. Try echoing out the query and run it in phpmyadmin or on the command line to check it works. Alternatively, use the [URL="http://uk2.php.net/manual/en/function.mysql-error.php"]mysql_error[/URL] function to display the error. … | |
Re: You could just do something like: [CODE=mysql] UPDATE `tablename` SET `hyperlink` = CONCAT('<a href="', `url`, '" target="', `target`, '">', `showingtext`, '</a>') WHERE `hyperlink` IS NULL OR `hyperlink` = ''; [/CODE] But make sure you back up your tables first, just in case this doesn't do what you want. R. | |
Re: Here's an example: [url]http://www.plus2net.com/php_tutorial/ajax_drop_down_list.php[/url] R. | |
Re: Hi You could try something like the following in a .htaccess file. To work, this will require you to have the apache rewrite module installed and enabled. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^user/(.*) profile.php?user=$1 </IfModule> This would then rewrite URLs like [url]http://example.com/user/username[/url] to [url]http://example.com/profile.php?user=username[/url] R. | |
Re: How about: [CODE=php] $categoryId = 22; $split = new page_split; $split->querystring = "id={$categoryId}"; // The call the other page_split functions afterwards... [/CODE] R. | |
Re: Without a form, you don't submit the input field value back to the server, so PHP cannot access the value. You could therefore: a) wrap it in a form and post to two.php, b) use JavaScript to get extract the value. Option A is the more reliable. R. | |
Re: Hi, What you need to do is combine your queries into one. [CODE=php] $sql = "SELECT `accounts`.* FROM `accounts` INNER JOIN `friends` ON (`friends`.`uid` = `accounts`.`id`) ORDER BY `created` DESC"; $result = mysql_query($sql); if(0 < mysql_num_rows($result)) { while(($account = mysql_fetch_assoc($result))) { // Use the account information } } [/CODE] Without … | |
Re: [QUOTE=ebanbury;1521480]Hi [CODE]WHERE property_details.prop_price <= '$_POST[prop_pricemin]' AND property_details.prop_price >= '$_POST[prop_pricemax]'[/CODE] [/QUOTE] You have you min and max parameters in the wrong way around: [CODE=mysql]WHERE property_details.prop_price <= 'prop_pricemax' AND property_details.prop_price >= 'prop_pricemin'[/CODE] Also, remember to escape anything coming from the browser before using in your SQL queries to avoid SQL injection attacks. … | |
Re: Hi, Firstly, and most importantly, you're not escaping parameters that come in over the URL before using them in an SQL query. That is a serious security risk. Secondly, are you checking that the user id is set in the session before use? Third, is your table called masterdb? And … | |
Re: Hi, Firstly, do you have to use JavaScript to submit the form? This isn't especially useful for users who do not have JS enabled. The problem I would think is because you have the element "markupcomplete" twice in your source code, on lines 24 and 25. It is possible that … | |
![]() | Re: Hi, I would suggest that you use MySQL to work out the date intervals. More information can be found [URL="http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_date-add"]here[/URL]. If you then amend the values of your select box to correspond to MySQL interval units, e.g. 1 DAYS, 2 DAYS, ..., 1 WEEKS, 2 WEEKS, 1 MONTHS, etc. You … ![]() |
Re: Hi, Why not use the latest stable release (3.0.5 I think) and then continue to upgrade the site as and when subsequent stable releases become available? R. | |
Hi everyone, As the thread title suggests, I am trying to think of the best way to maintain and synchronise local and remote databases. To explain this more clearly, I'll outline the scenario and my thoughts for tackling the problem. I have a website on a remote server, which obviously … | |
Re: Hi, I know this has been marked as solved, but I was intrigued by the concept. Could you not use a .htaccess file on your server to redirect the request for the image to an HTML, which outputs both a banner image, but also JavaScript, which changes the window location? … | |
Re: Hi, I'm not aware of the ability to [I]pass[/I] a variable from PHP to XML. One option to consider is to use PHP to generate the XML file. This would involve setting the correct content type headers so that when the PHP script is called, the resulting output is served … | |
Re: Hi, I can see your problem. One option would be to do something like: [CODE=php] $id = (int)$_REQUEST['id']; $nextSql = "SELECT * FROM articles WHERE id > {$id} ORDER BY id ASC LIMIT 1"; $prevSql = "SELECT * FROM articles WHERE id < {$id} ORDER BY id DESC LIMIT 1"; … | |
Re: Hi, A regular expression would be able to offer a suitable solution here. For example: [CODE=php] // This should find all numbers and store them in the array $matches preg_match_all('/^blah:(\d+)$/', $pageContent, $matches); [/CODE] [CODE=php] // This will replace all blah:number with the value of $pageName preg_replace('/^blah:(\d+)&/', $pageName, $pageContent); [/CODE] If … | |
Re: Hi, Try setting the page character encoding to UTF-8. R. ![]() | |
Re: Hi, If you're balance is already cumulative, why do you need to sum it up again? Could you not simply increment it but the desired amount each time? E.g. [CODE=mysql] -- Start balance is 0 UPDATE vendors SET balance = balance + 200 WHERE Code = 'ERL'; -- Balance is … |
The End.