139 Posted Topics
Re: As always it is best to do it yourself. However, this is one easy way that is recommended by Zend: [URL="http://www.zend.com/en/products/server-ce/"]Zend Server CE[/URL]. | |
Re: That's more or less how most people do it. Just be careful not to ever echo out your password while debugging :) You could just establish the connection within the include too. Saves you the trouble of having to always do that elsewhere. | |
Re: [QUOTE=Graphix;1334975]The book sounds like it has some good information on how to create web applications on the large-scale, but why is there a dog on the cover? Just wondering...;)[/QUOTE] :) O'Reilly technical books always have some animal on the cover. No rhyme or reason to it that I've ever figured … | |
Re: Before tackling the code, I have a question about your database schema. It seems that you have a category row for (potentially) every quote? I notice you store the quote id within the category record instead of the other way around. Often this is done with a bridge table -- … | |
Re: The result sets are always an array. Even if it contains one column. A couple minor changes are needed: [CODE] $productCountSql = "SELECT COUNT(*) as rowcount FROM products WHERE `user_id` = '" . $_SESSION['user_id'] . "'"; $productCountResult = mysql_query($productCountSql); $countProducts = mysql_fetch_assoc($productCountResult); echo "<tr><td>Products uploaded:</td><td>{$countProducts['rowcount']} products</td></tr>"; [/CODE] In the sql … | |
Re: The book you are using may be old. It relies on a very old, deprecated method called 'register globals.' With register globals, form input field names were automagically converted into global variables of the same name. That technique turned out to be a real security headache though and is not … | |
Re: hielo's example is actually calling itself (see the url in line 20) to retrieve and display the images. The loop that displays all the images is just there as a proof of concept. In practice, the second half (no id was passed) should return an http 404 error: [ICODE]header("HTTP/1.1 404 … | |
Re: You are concerned that a user can alter the url to retrieve records they are not meant to access. Sessions are probably only a piece of the solution for you. You will need to pass a key in the request for the record. I think we need a better sense … | |
Re: You are getting a syntax error in the query. Echo the query out so you can see what it contains. Also, you must scrub information being put into the database. Some characters need '[B]escaping[/B]' or you will either get a syntax error or you risk exposing your database to a … | |
Re: You are trying to refer to numeric keys in an associative array. If you run this script with error_reporting(E_ALL) turned on, you'll see notice messages like this: [ICODE]Notice: Undefined offset: 0 in C:\www\webroot\DaniWeb\arraytest.php on line 10[/ICODE] For an associative array, use [COLOR="Green"]foreach[/COLOR] instead. [CODE=php] <?php $geo_addr = array("number"=>1600, "zip"=>34208, "suffix"=>'', … | |
Re: For learning OOP with PHP I highly recommend [URL="http://www.amazon.com/Objects-Patterns-Practice-Experts-Source/dp/143022925X/ref=sr_ob_6?ie=UTF8&s=books&qid=1290976833&sr=8-6"]PHP 5 Objects, Patterns, and Practice[/URL] by Matt Zandstra. I read the first edition of this book and learned a LOT about OOP. The MVC pattern is discussed in the book. ![]() | |
Re: You can do this directly in the sql so you never receive unactivated users. [CODE=sql] SELECT `loginid`, `username`, `website`, `disabled` FROM `login` WHERE activated = 1 ORDER BY `loginid` [/CODE] In your query you also reference a 'disabled' column. So assuming that disabled gets set to '1' when a user … | |
Re: I've run into problems with Daylight Saving Time in the past. Your method of adding 86400 as 1 day in seconds breaks down when it crosses a daylight savings boundary. To further complicate things, date functions in PHP rely very heavily on the operating system hosting them and some OSs … | |
Re: This matches a sentence as you've defined it. It will also match across multiple lines: [CODE=php] <?php $rx = '/\b[A-Z].*[\.?!]/msU'; $testPhrases = "Alas, can I put time in a bottle? The quick brown \nfox jumps over the lazy dog. Sally \nsells seashells by the seashore."; $arFound = array(); $count = … | |
Re: You can use a switch statement to get the body of the text. If the body will be static, you can use file_get_contents to read in a text file into a string variable like this: [CODE=php] <?php ... $type = $_POST['type']; switch($type) { case 'intro': $body = file_get_contents('email/intro.txt', true); break; … | |
Re: You can write a simple function to do this. I use something like this: [CODE=php] function dbNull($value) { if(empty($value)) { return 'NULL'; } else { return "'".mysql_real_escape_string($value)."'"; } } // and you apply it like this: $add_proc = mysql_query(" INSERT INTO `proc` (active, title, desc, notes, link, tags1, tags2, tags3) … | |
Re: Your sql query has a syntax error in it. There should be a space after *: [CODE=php]$news_sql=mysql_query( "SELECT * FROM latestnews WHERE id = '$show' ");[/CODE] | |
Re: Are the columns seperated by spaces or tabs? If they are tabs, explode by "\t" instead of space. Flat files like that are often tab separated. If the separator is not a tab, then this is a "fixed column width" text file (sort of, see below.) You will have to … | |
Re: As long as $var1 and $var2 are primitive types and not objects, then $var2 is not a pointer to $var1 (however, I have read that PHP will store it internally with a pointer until the value of $var2 is changed to something else.) If you need $var2 to be a … | |
![]() | Re: On line 11: [ICODE]$check = mysql_query("SELECT * FROM upload_file WHERE name='$name'");[/ICODE] Is $name being set to anything outside the script snippet you posted? On line 20 [icode]$allowedExtensions=='png'[/icode] will NEVER be true. $allowedExtensions is an array, not a string. Use a function like basename() or pathinfo() to get the filename extension. … |
Re: Using phpMyAdmin it generates this: [CODE=mysql] CREATE TABLE `news` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR( 250 ) NOT NULL , `news` TEXT NOT NULL ) ENGINE = InnoDB COMMENT = 'For DaniWeb user The Prince Awah'; [/CODE] | |
Re: The complaint about $result is that you are appending to an uninitialized variable. $result could be initialized early in the function to an empty string for example. [iCODE]$result='';[/iCODE] I don't use list() very often so not sure about the other notices. Seems like "offset 1" would be the second element … | |
Re: Try losing the the single quotes around $construct. Instead you want to prepend the SELECT statement right? [CODE=php] $construct = "SELECT * FROM search WHERE $construct"; [/CODE] | |
Re: Sounds like you want a [I]regular expression[/I]. A regular expression lets you do pretty sophisticated pattern matching. However, be warned that they can be slow. [CODE=php] <?php $incomingString = 'Hi, my name is John Doe'; $rxIntroduction = '/HI,? MY NAME IS ([\w ]+)\.?/i'; $matches = array(); // preg_match() : http://php.net/manual/en/function.preg-match.php … | |
Re: Set up your link something like this... [CODE=php] <a href="update.php?emailid=<?=$rows['emailid']?>">Edit</a> [/CODE] Update.php then displays a form and handles the edit on a submit. | |
Re: [CODE=php] if ($ua="HelloWorld") [/CODE] You are using an assignment operator '=' instead of a comparison of equality '=='. [CODE=php] if ("HelloWorld" == $ua) { // do stuff } [/CODE] | |
Re: Looks like you downloaded the Source Code. Download the Windows binary version which comes as an installer. [URL="http://apache.cs.utah.edu/httpd/binaries/win32/"]http://apache.cs.utah.edu/httpd/binaries/win32/[/URL] httpd-2.2.16-win32-x86-no_ssl.msi --- .msi is a Windows extension indicating an installer. You can have it install Apache Web Server as a service that runs automatically upon start-up. You can turn it on and … | |
Re: [QUOTE=Kieran Y5;1343178]Hi, I am currently creating a CMS which will allow PHP code to be used but I need to make sure that certain functions are not used that can ruin the CMS. ... Is there any way of solving this problem??[/QUOTE] Are you using the eval() function to execute … | |
Re: MySQL does offer [URL="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html"]FULL-TEXT search[/URL] capabilities. What you describe sounds similar to that. It lets you search on strings, including multiple columns and returns a 'relevance' with each row. Hope that helps. | |
Re: If I understand your question/problem correctly, you say the session isn't being initialized. I don't see anything wrong with how you are doing it, unless tp_ser isn't being passed in. I see you are manipulating the form fields by hiding unused ones. Something may not be getting posted. To debug, … | |
Re: It's the single quotes around the variable $tz. [code=php] new DateTimeZone('$tz') // should be new DateTimeZone("$tz") [/code] | |
Re: [QUOTE=Bar2aYunie;1305395]Can anybody help me out here plz?[/QUOTE] Could you post the database schema for the table you are working with? It might make it easier to see what you want. If I read your question right, you could use SQL to do the selection of lowest or highest value for … | |
Re: It looks like you are not formatting the additional_headers (from email) correctly. See example 2 at: [url]http://php.net/manual/en/function.mail.php[/url] | |
Re: Aneeka, The usual pattern for this is to break it up into two pages. One is a list of employees that displays the data in a report. A link stores the key for each record and points to an edit form where a single employee record is edited. (That's the … | |
Re: You can't combine checkboxes within a select list. HTML just doesn't work that way. However, the effect would be the same a MULTIPLE selection box. See [URL="http://www.w3schools.com/tags/att_select_multiple.asp"]HTML <select> multiple Attribute[/URL] for details. This will let a user Ctrl-click (or Cmd-click on Mac) multiple choices from a select list. Since you … | |
Re: Most systems I have worked with test for a valid session with every call to a member's only section of a website. This includes RESTful scripts that should only be accessed by logged in users. If the session doesn't pass your validity test, redirect them to a login page. Basically, … | |
Re: When you loop over the DirectoryIterator object it is returning DirectoryIterator objects, not strings containing filenames. At the end of your script add a line like this: [CODE]echo "<pre>".print_r($fileNames,true)."</pre>";[/CODE] print_r will show you what $fileNames contains. You can use the [B]getFilename()[/B] method to get the filename and store it into … | |
Re: It sounds like you are setting a multiple page form/wizard. You can display the id to the user using something like this: [CODE] <!-- Page 2 of form. --> <form action="something.php" method="post" > <input type="hidden" name="id" value="<?php echo $_POST['id'];?>" /> <label>ID:</label> <?php echo $_POST['id'];?> <label for="more_info">More Info:</label><textarea name="more_info" id="more_info"></textarea> ... … |
The End.