505 Posted Topics
Re: Hi, In your example, you're essentially just outputting a string of HTML, with inline JavaScript to the browser, so yes, you can do that. That seemed quite simple (only if you know, of course), but does that answer your question, or have I misunderstood? R. | |
Re: Hi, $num_tape is out of scope. Try something like: [CODE=php] $numTape = isset($_COOKIE['num_tape']) ? $_COOKIE['num_tape'] : null; echo $numTape; [/CODE] Plus, always remember to sanitise variables from cookies, as they're easy to tamper with. R. | |
Re: Hi, By the sounds of your post, you have obviously got the unzipping part of your zip file upload process working. When iterating through the unzipped directory, why not do it recursively, checking each item within the directory to see whether it is a file or directory? Using the function … | |
Re: Hi, You can actually make Word documents by saving content to them in HTML format. E.g. [CODE=html] <html> <head></head> <body> <h1>Example title</h1> <p>This is some example content...</p> </body> </html> [/CODE] If I recall correctly, I think the head tag has to be empty, otherwise it screws up. However if you … | |
Re: Hi, On first thoughts, you're fetching an associative array. This means the array is indexed by column name. Hence you could try: [CODE=php] $sql = mysql_query('select category from tuck'); $categories = array(); while($row = mysql_fetch_assoc($sql)) { $categories[] = $row['category']; } echo $categories[0]; echo $categories[1]; [/CODE] R. | |
Re: Hi, I built a web crawler in PHP using the function exec to execute the unix shell command wget. It worked rather well. One thing to bear in mind with crawlers, is to add the URLs to a list, rather than recursively crawling them, as PHP has a recursion limit … | |
Re: Hi, What exactly are you trying to accomplish? What is the significance of the variable in PHP? Does it affect the content that is loaded? R. | |
Re: Hi, The error is due to your folder having incorrect permissions. I usually change my uploads directory to be owned by me, and in the same group as the webserver. E.g. chown -R rob:apache uploads/ I also then set the permissions to be read and write for the owner and … | |
Re: Hi, To understand regular expressions, read this [URL="http://www.php.net/manual/en/reference.pcre.pattern.syntax.php"]article[/URL]. It explains what the different modifiers do. With regard to extracting the content from between h1, h2 and h3 tags, you could use something like: preg_match_all('<h1[^>]*>([^<]*)</h1>', $matches); The '<h1' defines the opening tag of the header. The '[^>]*' should match any characters … | |
Re: Hi, How about: [CODE=html] <div class="field"> <input id="suitwearning" type="checkbox" name="suitwearing[]" value="HR Director"> <label for="suitwearing">HR Director</label> </div> <div class="field"> <label for="other">Other</label> <input id="other" type="text" name="suitwearing[other]" value="Sales Assistant" /> </div> [/CODE] Then when the form is submitted you can access the data like so: [CODE=php] $data = $_POST['suitwearing']; foreach($data as $field => … | |
Re: Hi Brian, Taking your example: [CODE] class Father {} class Son extends Father {} [/CODE] You can see that Son inherits/extends from Father. [B]Not[/B] Father from Son. Therefore, when you call the inherited function on the Father instance you will not get "Benz" outputted. However, take the following example: [CODE] … | |
Re: Based on the queries you have posted, why not try getting the album id and name in the same query result? [CODE=php] $sql = sprintf("SELECT `album`.`id`, `album`.`name` FROM `album` INNER JOIN `user` ON `user`.`id` = `album`.`user` WHERE `user`.`user` = '%s', $view); [/CODE] Then you need to retrieve only one result … | |
Re: Hi, When you go to load the page for the first time, can you not check the session for the current page: [CODE=php]$currentPage = isset($_SESSION['current_page']) ? $_SESSION['current_page'] : 'default_page_template';[/CODE] If the session is set, then load the current page, otherwise, revert to your default page. Then when the link on … | |
Re: Hi, By the look of your JSON code, multimedia is an array of objects. You could therefore try: [CODE=php]echo $result->multimedia[0]->caption;[/CODE] Or failing that, use var_dump to view the variable type of multimedia: [CODE=php]var_dump($result->multimedia);[/CODE] R. | |
Re: Can you provide details of the table structure and the actual query you're using? I cannot see any reason why what you're asking cannot be achieved using MySQL alone. R. | |
Re: Random thought, but try removing the ."'" from the end of line 10. R. | |
Re: Sorry, but no it won't. It will return a blank string, because you're missing the closing slash from your tag on line 4. R. | |
Re: Hi, PHP is a server-side language, so is unable to display the progess of an upload in the browser. To do so would require a client-side language, such as JavaScript. One good example that I have been using recently is [URL="http://www.swfupload.org/"]SWFUpload[/URL]. Give that a look. R. | |
Re: [QUOTE]$image = mysql_query("SELECT image.name, image.content, image.user_id, users.user_name, users.user_id FROM mystuff.image JOIN users WHERE users.user_name='$colname_Recordset1'");[/QUOTE] You're correct. The problem is with your query. You join the user table, but don't specify what fields to use for the join. Try: [CODE=php] $image = mysql_query("SELECT image.name, image.content, image.user_id, users.user_name, users.user_id FROM mystuff.image JOIN … | |
Re: Could you not just add a distinct or group by to the SQL query to only retrieve unique results? R. | |
Re: Have you checked that your IE browser has cookies enabled? | |
Re: Hey, How about trying something like this: [CODE=php] $excludeExtensions = array('jpg', 'gif', 'png'); $directory = '/path/to/directory'; $files = scandir($directory); foreach($files as $file) { if(!in_array(pathinfo($file, PATHINFO_EXTENSION), $excludeExtensions))) { unlink("{$directory}/{$file}"); } } [/CODE] This code will iterate through all of the files found in a target directory. It will then delete any … | |
Re: Hi, Try reading the following. It covers both ajacency list and nested set tree models. [url]http://dev.mysql.com/tech-resources/articles/hierarchical-data.html[/url] Even if you're not using MySQL, the principles explained within this article will still be relevant. R. | |
Re: Hi, Try: [CODE=mysql] SELECT * FROM `property` INNER JOIN `floorvalue` ON `property`.`id` = `floorvalue`.`id` ORDER BY `floorvalue`.`rentmin` ASC LIMIT 1 [/CODE] R. | |
Re: Hi Luke, What you're asking sounds simple enough. All you need to do is use two for loops to iterate through the various options. E.g. [CODE] $startTime = '06:30'; $endTime = '10:45'; $options = array(); // Split start and end times using colon as delimiter $startTime = explode(':', $startTime); $endTime … | |
Re: Okay, firstly, to fix the white lines in IE, I believe you'd need to add the following to your css stylesheet for the button table. [CODE] table { [INDENT]border-collapse: collapse;[/INDENT] } [/CODE] Secondly, I think you're going about this the wrong way. The use of background images are correct, but … | |
Re: Hi, Try this: [CODE=php] $arrInput = array('abc', 'def', 'ghi', 'jkl', 'mno', 'pqr'); $arrOutput = index_array($arrInput); function index_array($arrInput) { $arrOutput = array(); $intIndex = 0; if(is_array($arrInput)) { while($intIndex <= count($arrInput)) { if(isset($arrInput[$intIndex]) && isset($arrInput[$intIndex + 1])) { $arrOutput[$arrInput[$intIndex]] = $arrInput[$intIndex + 1]; } $intIndex += 2; } } return $arrOutput; } … | |
Re: Hi, As I'm sure you know, 404 means the page doesn't exist, as the error message said. Is it definitely the correct URL? Have you tried it with both HTTP and HTTPS? There might not be an automatic redirect if one or the other is required. With my site FTP, … | |
Re: Hi, You could do something like: [CODE=mysql] SELECT `name`, COUNT(`name`) FROM `member` GROUP BY `name`; [/CODE] And repeat this for each column. Or you could combine them all into a single query, by using a subquery for each column. R. | |
Hi, I have two databases (live and staging). Extra columns have been added to various tables within the staging database by another developer while they were extending the websites functionality. Now has come the time to put the new functionality live, which means taking the staging database schema, creating a … | |
Re: Hi, If you're storing the id in a database, why not use an auto-increment ID field? R. | |
Re: Hi, I think the issue is with the return statement. Try removing it, and let the function naturally return instead. R. | |
Re: Hi, Assuming your html file has an .rhtml, .erb or basically an extension that will ensure it is run through the ruby parser, then you can do this: [CODE=ruby] <div id="bubble" class="bubble" style="background: <%= event.icon %>"> </div> [/CODE] R. | |
Re: Have you considered that if the server is offline, how would it serve a web page telling the user such? R. | |
Re: Hi, When I want to entirely separate my PHP and HTML content, I tend to use placeholders in my HTML code, and replace these using PHP. A highly simplified example would be: [CODE=html] <!-- this file might be called index.html or index.tpl, etc <html> <head> <title>{title}</title> </head> </html> [/CODE] Then, … | |
Re: A nicer alternative might be to use the [URL="http://uk2.php.net/manual/en/function.nl2br.php"]nl2br[/URL] php function. R. | |
Re: Hi, Can you not change the web root of your server to point to the public folder? E.g. /var/www/ryzalyusoff.com/public (or your equivalent path) Then you can put any files you would like to prevent direct access above the web root, hence only scripts executing on your server will be able … | |
![]() | Re: Hello, There are numerous ways you can pass a variable from one page to another: - Pass it on the URL and use $_GET to retrieve the value; - Post the value to the new page and use $_POST to retrieve the value; - Store the value in the $_SESSION … |
Re: Hi, A really simple way to do this would be the following: [CODE=php] // Array containing profane words $arrProfanities = array('these', 'are', 'the', 'words', 'I', 'want', 'to', 'filter'); // String containing content you want to filter for profane words $strContent = 'does this string contain any words I want to … | |
Re: Hi, A more suitable method to look at might be [URL="http://uk3.php.net/manual/en/function.parse-url.php"]parse_url[/URL]. Specifically, to get the host name out of a URL you would use: [CODE=php] $strUserUrl = 'http://www.example.com/this/is/a/page.html'; $strHost = parse_url($strUserUrl, PHP_URL_HOST); // $strHost = www.example.com [/CODE] Or you could use the method without specifying a single component and it'll … | |
Re: Hi, Firstly, when implementing a search, I would be inclined to use the [I]like[/I] syntax in your select query. For example: [CODE=mysql] SELECT * FROM `songs` WHERE `song` LIKE '<song name>'; [/CODE] This can then be taken further to include the use of the wildcard character - %. For example: … | |
Re: Hi, Instead of using a <br /> tag, try using: [CODE=php] $strNew = "This is my string\r\n"; [/CODE] Also, I notice that you're overwritting the entire file content during each iteration of your code. If you want to [B]add[/B] another line, you'll need to read the content from the file … | |
Re: Thank you for your message DarkBerzerk, although it didn't make that much sense. [QUOTE=DarkBerzerk™]if u that much good and give us bad rates...what about say better idea? when some one ask for some thing and some other say idea and just say this idea is bad...say ur idea..[/QUOTE] I don't … ![]() | |
Re: Have you considered using a WYSIWYG editor such as [URL="http://tinymce.moxiecode.com/"]TinyMCE[/URL]? This has headers, paragraphs, hyperlinks, tables, images, etc. R. | |
Re: Hi, How about the following... [CODE=php] <?php // Define hits count and hit counter file $intHits = 0; $strCountFile = 'hit_counter.txt'; // Get existing hits count from file, if file exists if(file_exists($strCountFile) && is_readable($strCountFile)) { $intHits = (int)file_get_contents($strCountFile); } // Echo hits echo $intHits; // Increment hits - this will … | |
Re: Syntaxically, it is correct. I have two comments however: 1. You really should validate every variable being sent to the server from the browser. Otherwise you leave your website open to MySQL injection and XXS attacks. 2. Not really important, however if your string is enclosed in " (double quotes), … ![]() | |
Re: Hi Shane, Possibly stating the obvious, but it seems that you're only returning the form, you're not echoing or printing the form. Do you do this somewhere else when the confirmDelete function returns? R. | |
Re: Hi, You could use tokens... E.g. [CODE=js] function func123() { $(document).ready(function(){ $.getJSON('http://127.0.0.1/token/1234567890', function(res){ ...................... }); }); } [/CODE] And resolve the token on the server side to forward the request to your target script: [url]http://127.0.0.1/~nertos/file/my_web/file.php[/url] R | |
Re: Hi, I think the closest you can get is to use the function [URL="http://php.net/manual/en/function.get-class-methods.php"]get_class_methods[/URL](), to which you pass the class name for which you want the method. Although this doesn't provide a list of the method parameters. [CODE=php] // E.g. If calling from within the class for which you want … |
The End.