505 Posted Topics

Member Avatar for ben.marks

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.

Member Avatar for ben.marks
0
171
Member Avatar for fuston05

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.

Member Avatar for fuston05
0
115
Member Avatar for TySkby

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 …

Member Avatar for TySkby
0
163
Member Avatar for altarek

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 …

Member Avatar for blocblue
0
100
Member Avatar for ben.marks

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.

Member Avatar for ben.marks
0
176
Member Avatar for Joe34

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 …

Member Avatar for lordspace
0
248
Member Avatar for LiQuid.Ace

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.

Member Avatar for blocblue
0
147
Member Avatar for shg234

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 …

Member Avatar for blocblue
0
149
Member Avatar for Joe34

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 …

Member Avatar for blocblue
0
478
Member Avatar for Ash2Dust

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 => …

Member Avatar for blocblue
0
136
Member Avatar for Brianbc

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] …

Member Avatar for Brianbc
0
123
Member Avatar for AdriftUniform

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 …

Member Avatar for AdriftUniform
0
251
Member Avatar for ichigo_cool

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 …

Member Avatar for blocblue
0
150
Member Avatar for cj333

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.

Member Avatar for cj333
0
82
Member Avatar for jj.amonit

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.

Member Avatar for jj.amonit
0
176
Member Avatar for sedalnas
Member Avatar for sedalnas
0
131
Member Avatar for Mi-Dia

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.

Member Avatar for blocblue
0
335
Member Avatar for amit_kuetcse2k5

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.

Member Avatar for blocblue
0
153
Member Avatar for phpDave

[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 …

Member Avatar for phpDave
0
80
Member Avatar for edmundoswald
Member Avatar for ankit.pandey3

Could you not just add a distinct or group by to the SQL query to only retrieve unique results? R.

Member Avatar for Borzoi
0
129
Member Avatar for EricIskhakov
Member Avatar for Sorcher

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 …

Member Avatar for Sorcher
0
132
Member Avatar for Ashwini123

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.

Member Avatar for blocblue
0
62
Member Avatar for Venugopal Ravi

Hi, Try: [CODE=mysql] SELECT * FROM `property` INNER JOIN `floorvalue` ON `property`.`id` = `floorvalue`.`id` ORDER BY `floorvalue`.`rentmin` ASC LIMIT 1 [/CODE] R.

Member Avatar for blocblue
0
71
Member Avatar for lukemaister

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 …

Member Avatar for lukemaister
0
108
Member Avatar for Bram2

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 …

Member Avatar for crisane_love
0
93
Member Avatar for mayuri_desh

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; } …

Member Avatar for hielo
0
184
Member Avatar for hassancool

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, …

Member Avatar for Excizted
0
152
Member Avatar for webguy6

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.

Member Avatar for blocblue
0
141
Member Avatar for blocblue

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 …

Member Avatar for blocblue
0
901
Member Avatar for dandixon

Hi, If you're storing the id in a database, why not use an auto-increment ID field? R.

Member Avatar for chintan@dani
0
119
Member Avatar for virtualvinodh

Hi, I think the issue is with the return statement. Try removing it, and let the function naturally return instead. R.

Member Avatar for virtualvinodh
0
246
Member Avatar for stilllearning

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.

Member Avatar for blocblue
0
115
Member Avatar for private bob4

Have you considered that if the server is offline, how would it serve a web page telling the user such? R.

Member Avatar for 84hd0ns
0
81
Member Avatar for Tracie-marie

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, …

Member Avatar for Tracie-marie
0
159
Member Avatar for valonesal

A nicer alternative might be to use the [URL="http://uk2.php.net/manual/en/function.nl2br.php"]nl2br[/URL] php function. R.

Member Avatar for valonesal
0
116
Member Avatar for samsons17

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 …

Member Avatar for blocblue
0
168
Member Avatar for kirtan_thakkar

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 …

Member Avatar for bouhbob
0
4K
Member Avatar for whiteyoh

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 …

Member Avatar for blocblue
0
92
Member Avatar for nick3592

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 …

Member Avatar for nick3592
0
440
Member Avatar for asahmed

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: …

Member Avatar for asahmed
0
148
Member Avatar for reza.adinata

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 …

Member Avatar for reza.adinata
0
149
Member Avatar for wrstrong

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 …

Member Avatar for diafol
0
186
Member Avatar for DarkBerzerk™

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.

Member Avatar for DarkBerzerk™
0
124
Member Avatar for reza.adinata

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 …

Member Avatar for reza.adinata
0
241
Member Avatar for zia zia

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), …

Member Avatar for rajarajan2017
0
157
Member Avatar for Emeraldwebshane

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.

Member Avatar for Emeraldwebshane
0
112
Member Avatar for nertos

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

Member Avatar for sergb
0
1K
Member Avatar for LordWEB

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 …

Member Avatar for LordWEB
0
92

The End.