Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. This is not PHP but more towards HTML if I am reading your post correctly. You usually see this type of thing on long pages that scoll quite far down the page. Such as a link that says Go to TOP at the bottom of a page. Then you'll place at the top of your page (just before the body tag). [code]<a name="top"></a>[/code] The code below is the linked that'll be a placed at the bottom of the page. [code]<a href="#top">Go to Top of page</a>[/code] If you have long page where you have to scrol then you click the Goto top of page link and it'l autotmatically go to the top of the page. This is the same affect that FAQ's use. Heres an example: [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>   <title></title> </head> <body> <a name="top"></a> <a href="#bottom">Go to bottom</a> <h1 style="margin-bottom: 2000px;">Top of Page</h1> <a name="bottom"></a> <a href="#top">Top of Page</a> </body> </html>[/code] If you click the link [i]Go to bottom[/i] it'll go to the bottom of the. Same applies to the [i]Go to Top[/i] link at the bottom but it goes to the top.
  2. Actaully it does. Use IE on the example site I posted in my last post. In order for IE to automaitcally center an element on the page it needs to meet the following terms:[list][*]Valid DOCTYPE - without this IE goes in quirks mode, meaning doesn't render page corectly (every HTML page should have DOCTYPE)[*]the tag you are centering must have a width set, eg: width: 700px[/list]If you do not have either of the above IE won't center your page. Try it out with this code: [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>   <title>IE test with auto margin</title> <style type="text/css"> #container {     width: 600px;     border: 1px solid #FF0000;     margin: 0px auto;     padding: 50px; } </style> </head> <body> <div id="container">This div is centered in IE!</div> </body> </html>[/code]If you have a look the div is conainter is centerd in IE. Now if you take out the DOCTYPE and refresh the page IE will no longer center your page, IE is now in "quirks mode". As long as you have a DOCTYPE and a width defined IE will use the auto margin. EDIT: By the way I am not using IE7, I am using IE6
  3. If you want to refernce aboutus.php as index.php?aboutus then you will need to use mod_rewrite. PHP hasn't got the power to change how you refernce your files in the URL. Have a look at [a href=\"http://www.workingwith.me.uk/articles/scripting/mod_rewrite\" target=\"_blank\"]this[/a] tutorial on mod_rewrite and what it can do.
  4. You use my previous SQL Query with mysql_num_rows. You dont need to count how many times of the same username is in the database, becuase of the unique identifier option will only 1 occurance of the same username in the database.
  5. Yes there, and that is to change your users_row_name row to a unique identifier. You can do this in PHPMyAdmin by editing the users table and clicking the Unique Identidier option on theu sers_row_name row. This way MySQL will check when it inserts a new record that the username being inserted doesn't already exist users_row_name row in the database. If there is then if you have the [i]or die(mysql_error())[/i] clause after you do mysql_query function MySQL will report back with an error.
  6. Use sessions, so after this line in index.php: [code]require ("data.php");[/code]Place: [code]$_SESSION['minerals'] = $minerals;[/code] Then on form.php do this: [code]<?php error_reporting(E_ALL & ~E_NOTICE); $minerals = $_SESSION['minerals'][/code] Or, this just come to me while I was doing this post. Is to have hidden form element form. So in index.php change it to this: [code]<?php error_reporting(E_ALL & ~E_NOTICE); require ("data.php"); echo <<<HTML <form action="form.php" method="POST"> Enter your username: <input type="text" name="name" /><br /> Enter the amount of minerals you wish to bet: <input type="text" name="minbet" /><br /> <inout type="hidden" name="minerals" value="{$minerals}" /> <input type="submit" /> </form> HTML; echo "You currently have {$minerals} minerals <br />"; ?>[/code] Now in form.php chnage it to this: [code]<?php error_reporting(E_ALL & ~E_NOTICE); echo "Welcome {$_POST["name"]} <br />"; echo $_POST['minerals']; ?>[/code]
  7. You can do a SELECT query but use the WHERE clause ie: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] users_row_name [color=green]FROM[/color] [color=orange]user_table[/color] [color=green]WHERE[/color] users_row_name [color=orange]=[/color] [color=red]"someNameHere"[/color] [!--sql2--][/div][!--sql3--] Then in PHP you use the mysql_num_rows function and check whether the query returned more than one name. Heres some code: [code]<?php $query = "SELECT users_row_name FROM user_table WHERE users_rwo_name = "someNameHere"; $result = mysql_query($query); if(mysql_num_rows($result)  !=  '1') {     echo "unfortunatly that name has alread been taken, please try another"; } else {     echo "Hay! You're in luck that name is available"; } ?>[/code] Also I would recommend you to change the row that stores your website users to be Unique.
  8. Thanks moberemk, Next time you come across something like this it would be nice if you could use the "Report" button ([img src=\"http://www.phpfreaks.com/forums/style_images/1/p_report.gif\" border=\"0\" alt=\"IPB Image\" /]) when you click that you fill in the form, say I found a double post/thread) We'll get an email and link to problem thread an we'll be able to deal with problem. Thread Closed
  9. I dont like to code in short, like [i]margin: 0px auto[/i] I prefer to do my CSS in full. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Also, if I were you, I'd go to the library and pick up a good CSS book[/quote] Was that directed at me? Why do I need a good CSS book for?
  10. D0 you site use Apache server (80% chance you will)? If you do look into mod_rewrite. Note in order to use mod_rewrite your hosting accound must be able to use .htaccess files and has Mod Rewrite enabled.
  11. is there a file called [b]config.inc.php[/b] located inside the admin folder? As currently PHP cannot find that file in side the admin folder.
  12. This should do it: [code]echo '<a href="pagename.php?action=Table&id="' . $row['IDNumber'] .'">'  . $row['FieldName'] . '</a>';[/code]
  13. The session data is not stored in the cookie, well only the SESSID of the session is stored in the cookie, but the session data is stored on internally on the server in a specified folder, such as a folder called tmp. You cannot tell PHP to put any POST or GET data to be automatically placed into a SESSION which is not a very good way of doing things.
  14. Do you mean where a variable is an of a numric value or holds a string? You can do this: [code]<?php $var = "01256"; // $var is a numric value if(is_numeric($var)) {     echo '$var is number!'; } else if(is_string($var)) {     echo '$var is a string!'; } else if(is_bool($var)) {     echo '$var is boolean (TRUE / FALSE)'; } ?>[/code]Ther are other is_* style functions in PHP like is_num, is_array, is_int etc. Try changing the value of $var to $var = TRUE this time it'll say its a boolean variable.
  15. DOnt really understsnd your problem but. Is the content (#content) box the main box that all your content is in and you want that to aline in the center of the page? If so add the following code to your #content style: [code]margin: 0px auto 0px auto;[/code] This will then center your page like [a href=\"http://homepage.ntlworld.com/cshepwood/BranchingOutDesigns/\" target=\"_blank\"]this[/a]. In order for that code to work properly you will need to state a width for the #content style (which you have) and to have a valid DOCTYPE at the very top of your HTML file. It should work in most browsers including IE!
  16. Use fopen to open the file then fwrite that'll erase al data in the file.
  17. If have a look at [a href=\"http://www.php.net/manual/en/function.fopen.php\" target=\"_blank\"]fopen[/a] and [a href=\"http://php.net/manual/en/function.fwrite.php\" target=\"_blank\"]fwrite[/a] you should be able to see how to do it. If not I'll post an example.
  18. Just curious by waht was the error message? But anyway glad you found out what to do.
  19. The way in which you are coding PHP isn't the most efficent way. You open and close a PHP statement on virtually every line. This I would not recommend to do as it is waste of time. I would only recommend to go in and out of PHP when you want to echo out large blocks of HTML. Such as your table. Below is your code which has been slightly recoded syntax wise: [code]<?php include ("header.php"); if ($stat['company_status'] == 1) {     echo "<p>Your already in a company.</p>"; } else {     if($join > 0)     {         $companyssel = mysql_query("SELECT * FROM `companys` WHERE `id`=$join ");         while ($companys = mysql_fetch_array($companyssel))         { ?>     <p>Are you sure you want to join <b><?php echo $companys['name']; ?></b>?</p>     <table width="25%" height="39" border="0" cellpadding="0" cellspacing="0">       <tr>         <th scope="row">           <form method="post" action="join.php?join=<?php echo $companys['id']; ?>">             <input type="submit" value="Yes" />           </form>           <form method="post" action="district.php">             <input type="submit" value="No" />             </form>           </th>         </tr>       </table> <?php         } // this was the missing closing bracket     }     else     {         echo "<p>Error occurred. If this problem persists, please contact a developer.</p>";     } } ?> <p align="right">   <input name="button2" type="button" onclick="history.back()" value="Back"> </p>[/code]As you can see there is far less open and closing of PHP statements. I also indented your code too. This way it is easy to see that your { and } pair up easier. Every time you code an { you should indent it(about 4 spaces, you can do by hitting the Tab key (the one above Caps Lock)) by one. Then when you type } you de-indent it by one (backspace once or 4 times if you used spaces). Your code now "flows" enabling your code to be readable.
  20. If you are getting warning messages then you will want to get them sorted out otherwise you script will not work as you expect it to. If you want to turn your errors off you'll need to access to your php.ini file and turn [b]display_errors[/b] (located near line 357) to Off.
  21. MySQL, MSSQL, PostegreSQL are all different versions of SQL. SQL is the main langauge used in any database. So yeah if you learn SQL you should be able to to use any other database, however some databases may have different SQL syntax compared to others. I can't really tell you which database to go with as I have only developed with one database which is MySQL. MySQL is the most common database used by webhosts.
  22. You use this: [code]$comment = addslashes($_POST['comment']);[/code]
  23. wildteen88

    fwrite

    0644 only allows to read the file. You cannot edit the file with that CHMOD value. To be able to edit a file you'll need to give the file a CHMOD value of 0777. Now I don't think chnaging the permissions of the file 0777 will affect the file much as you are on Windows using IIS. Windows doesn't have CHMOD. Only *unix and Macs have CHMOD. So I'd strip out your chmod function as it isn't going to do anything. My guess is that the file you are trying to edit is read-only (this you can check in your FTP Client by right clicking 46.txt and selecting properties and making sure the Read-only checkbox is unticked) or your webhost may be disabling the use of fopen.
  24. If you are dealing with submitting data from a form I would use the POST method and use $_POST to retrieve the submitted data. 99% of the time. I rarely use the GET method on a form to submit data as the data is showing in the URL which may show personal information, such as passwords etc. POST is more secure as it is hidden and the user can't see what data is being submitted. The only time I use $_GET is on links when I need to send variables to my script to show different information. When I'm send data over the url I usually only accept certain keywords/numbers to be sent over. Such as if I only want numerical data to be sent over the URL I'll check the data that is being sent is a of a numerical value like so: [code]<a href="?var=0125698">Send 0125698 over the url</a> | <a href="?var=hello">Send hello over the url</a> <hr /> <?php if(isset($_GET['var']) && is_numeric($_GET['var'])) {     echo "Var is number!"; } else {     die("<b>Script Terminated</b> - No/Invalid data being sent!"); } ?>[/code]When you run the script the first time it'll display: [b]Script Terminated[/b] - No/Invalid data being sent! Untill you click the first link. When you click the secound link it'll show the above message. You should always validate any user input from any user as you don't know who is sending what to your page. The same applies to $_POST too.
  25. I'm a little confused here. Do you want to know what System, Build Date, Configure command, Server API etc means when you use phpinfo? If so that is pretty much straight forward, I'll list a few here. System means the system or server that PHP is running off in your case the server is a Linux OS and appears to be running off box number 86 from bluehost.com. Basically the System box is just holds information about the system it is running of. This you dont need to know about when you are programming in PHP, as PHP can run on any OS/server. The next one is build date. This means the date that your version of PHP was comiled (setup) on the server. Now the important part. The Config Command. This is only used on Operating Systems such as *unix and Macs. This is done when users setup PHP on an OS other than Windows. Users need to compile PHP with all the extension/features they would like in their setup of PHP. There are many possible configurations you can compile PHP with. The next part Server API (Application Programming Interface). PHP can run in two different API - CGI or an Apache Module. Again nothing you need to worry about here as both have the same features. As AndyB said above you can get more information about the phpinfo file by going to php.net and reading the fine manual which is virtually fool proof. The rest of the infor phpinfo returns can found by reading through purl=http://uk.php.net/manual/en/ini.core.php#ini.expose-php]Description of core php.ini directives[/url]. The main things you shoud look out for when coding in PHP is whether say it has MySQL support if you are going to be using a MySQL Database to store login information for example. Or whether [a href=\"http://uk.php.net/register_globals\" target=\"_blank\"]regsiter_gloabls[/a] is set to on or off.
×
×
  • 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.