Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Is date_ofbirth the name of a form field? If it is use $_POST['date_ofbirth'] to get the value for that field, like so: [code=php:0]$date = my_date($_POST['date_ofbirth']);[/code]
  2. You should only need to use the htmlentity for certain characters, such as triangler brackets (<>) to stop the browser from intepreting them, &nbsp; for placing two or more spaces between words/letters. &copy; to display the copyright symbol etc. You shouldn't use the ASCII value for letters, as there will be no reason to.
  3. Note really. Unless you setup a constent called MY_ROOT, which has the value of D:/Apache/hameed/ like so: [code]define('MY_ROOT', 'D:/Apache/hameed/'); echo MY_ROOT;[/code] When creating/using constants they must be in uppercase. Then when you want to use MY_ROOT you do this: [code]echo realpath(MY_ROOT);[/code]
  4. stripos is a PHP5 only function, you must be using PHP4 or lower. So you'll have to use strpos
  5. No problem, Its a common problem most new comers face, I even fell into the same trap too when I started.
  6. Make sure the form your select menu is contained in has a name of album in order that javascript to work.
  7. &nbsp; is the htmlentity (ASCII, i think) of a space. This is not depreciated. All characters has an ASCII equivilant. Most people use &nbsp; to add in two or more spaces between words, as using a normal space will only work with 1 space, but not if there is 2 or more spaces directly after each other, as the browser ignores it. [url=http://www.lookuptables.com/]This[/url] site shows all the ASCII values for most characters, look at the HTML coloumn for the last three columns.
  8. You'll need to create a form first, which will state where the data will be sent to and the method (GET/POST) then use javascript to submit the form, using the onchange attribute for the drop down menu. Like so: [code]<form action="page.php" name="album" method="post">   <select name="album_name" onchange="document.album.submit()"> <?php       $usrname = $_COOKIE[user_cookie];       $conn = OCILogon("kevin", "kevin", "") or die ("connection failed");       $stmt = OCIParse($conn, "select * from album where user_name = '$usrname' ");       OCIExecute($stmt);       echo "Executed";       while (OCIFetch($stmt))       {       $record =OCIResult($stmt, 'ALBUM_NAME');       echo " <option value = '$record'> $record</option>";       }   OCIFreeStatement($stmt);   OCILogoff($conn);   ?>   </select> </form>[/code] Change page.php to the page you want the form to be submitted to.
  9. The more you program the better you get as you are gettig to understand the language as well as gaining experience. So rather than sitting down and reading a book. Go away sit down for an hour or two and see what you come up with. For my first PHP project I learnt how to create a simple app which stores jokes and displays them. After completing the turorial I went away and basically took it apart and put it back together again learning how it works etc, then I set about creating my own simple guestbook from what I had learnt. Within a couple of hours I had a very basic functioning guestbook and learnt alot, with how to use if/else statements, adding  and retrieving data from a database, basically the simple stuff. I must of created about 5 different version of the guestbook, each version getting more complex adding more features etc. Also a good thing to do is to download other peaoples work and have a look through the source code, hacking it apart seeing how it works, how they have created it etc.
  10. This is because PHP doesnt send a request through to Apache, to retrive info on a directory/file, include/requiring a file etc or when dealing with files/folders. PHP uses its own request to do this. So if you tell PHP to go to /my_root, it'll goto the root of your hard drive and look for a file//folder called my_root, it wont use the apache alias you setup as it isn't sending a reguest through to apache.
  11. Yeah you need to return $date2 like so: [code]function my_date ($formdate) { $date1 = $formdate $date2 = date("Y-m-d",strtotime($date1)); return $date2; }[/code] Now to use the value returned from your date function you so this: [code]$date = my_date('25-12-2006');[/code] You now use the $date variable within your SQL Query.
  12. In the check function for your iplog class you are trying to access an internal variable called ip within that class, which doesnt exists, so $this->ip will not return anthing. So to solve this, first setup an blank ip var within the class: [code]class iplog {     // initiate our class variables     $ip = '';     // rest of class here }[/code] Now to to set a value for ip variable out side of the class you do this: [code]$iplog->ip = $_SERVER['REMOTE_ADDR'];[/code] Now when you call your check method $this->ip will now return the value of the ip variable. Or pass the $ip var through to the check function, like so: [code]if($this->check($ip)) {[/code] Then with your check method do this: [code]function check($ip) { $sql = mysql_query("SELECT ip FROM log WHERE ip = '{$ip}'"); if(mysql_num_rows($sql) == 0) { return true; } else { return false; } }[/code]
  13. You need to surround the value of of the value attribute with quotes: [code]<input name='postcode' type='text' id='postcode' value="{$_SESSION['postcode']}">[/code] Also i you start your echo statement with an " then you'll need to escape any instance of " within your echo statament, apart from the ending ". Like so: [code]echo "<input name=\"postcode\" type=\"text\" id=\"postcode" value=\"{$_SESSION['postcode']}\">";[/code] Or if you are echoing out large chuncks of HTML use HEREDOC: [code]echo <<<HTML td><strong>Address 4</strong></td>       <td><input name="address4" type="text" id="address4" value="{$_SESSION['address4']}"></td>     </tr>     <tr>       <td><strong>Postcode<span class="rederror">*</span></strong></td>       <td><input name="postcode" type="text" id="postcode" value="{$_SESSION['postcode']}"></td>     </tr>       <tr> HTML; [/code]
  14. You have ouput at line 6 in more_metrics.php. Whats is at lines 4 - 8? If its output text/html/whitespace you cannot use session_start after the output. Make sure session_start(); is the first line of code for any page that needs session.
  15. You can with eval: [code]<?php if(isset($_GET['a'])) {     $a = $_GET['a'];     eval("{$a}('hey this works');"); } ?> <br /> <a href="?a=echo">Test</a>[/code] However be careful with the use of eval. Make sure there is no nasty code stored within the 'a' variable.
  16. Or a cookie, works basically the same as a session.
  17. You should provide a selection of fonts, eg for your CSS: [code]body {     font-family: Arial, Verdana, Helvetica, sans-serif; }[/code] The browser, will use Arial if its available, else it try to use Verdana if its available, after that it'll try the next font and the one after that etc. But it is not recommened for you to use non-standard fonts for text in webpages, however its fine for images. However if you want to use a non-standard font you can do, but I forgotten the method EDIT the method is called embeded fonts, using [url=http://www.microsoft.com/typography/web/embedding/weft2/default.htm?fname=%20&fsize=]WEFT[/url]
  18. by any chance is the file you are serving called header.html? As thats is the only reason why this could be why its adding that to your page. If you have afile called header.html Apache (if thats your server) will append that to the directory index.
  19. This: [code]echo "<a href='http://www.sitea.com">";} [/code] should be this: [code]echo '<a href="http://www.sitea.com">';} [/code]
  20. This article [url=http://www.stylegala.com/articles/no_more_css_hacks.htm]here[/url], shows how to use browser specific CSS with PHP. It shows how to correctly detect the user agent etc.
  21. What moberemk said pretty much sums it up. [quote]All I can say is that the code is easier, the design is more flexible, it makes semantic sense, and it makes your site more accessible to the disabled.[/quote] When you use tableless layouts you can reduce the amount of HTML code by probably more than 50%! Which can mean less file sizes and faster page loades. However your stylesheet size will go up. I am trying to find a decent article I found when I was trying to understanding tables vs tableless layouts, I cant find it at the mo.
  22. To get the user users agent (the browser) you use $_SERVER['HTTP_USER_AGENT'] You shouldn't rely on this variable too much as this can be fooled and some browsers dont send this, or disguise themeselfs. The following is what is produced: IE7/Win: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Opera9/Win: Opera/9.00 (Windows NT 5.1; U; en) FF1.5/Win: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
  23. Please read [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]this FAQ[/url]
  24. No its because your creating a function called data. But there is already a predifined function called date. So change you code to this: [code]function my_date ($formdate) { $date1 = $formdate $date2 = date("Y-m-d",strtotime($date1)); }[/code] The when ever you want to call your data function use my_date
  25. Or simply run this: [code]<table border="0" cellpadding="2" cellspacing="1" width="900" bgcolor="#333" align="center">   <tr style="background-color: #e1e1e1;">     <th width="35%">Variable</th>     <th>Value</th>   </tr> <?php foreach($_SERVER as $key => $value) {     echo '  <tr>     <td style="background-color: #f1f1f1">$_SERVER[\''. $key . '\']</td>     <td style="background-color: #ffffff">' . $value . "</td>   </tr>\n"; } ?> </table>[/code] to see what each server variable is set to.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.