Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Look into to using the nl2br function.
  2. Why dont you just use the number_format functon? It does all the formating for you. All you need to do is provide the thousands and decimal seperator. See SA's post above.
  3. Yeah I editted my post. I made a mistake with the code. Try the new code: [code=php:0]$num = '1235'; ${'_' . $num} = $num; echo $_1235;[/code]
  4. You mean you wnat to create a variable that has the same name as its value? Ie you ahve variable holds the number 1234 and you want to create a new variable which has the name 1234 and holds the value of 1234 If you do then you'll want to use curly braces: [code=php:0]$num = '1235'; ${'_' . $num} = $num; echo $_1235;[/code] Note if you want to the variabled to be $1234, then you cannot do that as variable names must not start with a number.
  5. By white spaces you mean line breaks/carriage returns Eg you have a string like this: [code]This stirng has line breaks in it[/code] But when you go to echo the string it displays like this: [code]This stirnghas line breaksin it[/code] If that is whats happing its becuase the browser ignores whitespace chars. In order for the browser to parse whitespace characters you will need to force it, by either using the preformated text tag ([nobbc]<pre>text here</pre>[/nobbc]). Or you'll have to convert the new lines into a HTML line break ([nobbc]<br />[/nobbc]) using a PHP function called nl2br() You're best of going with the PHP version. SO uses this as the PHP code: [code=php:0]<?php function therror($error) {     print "<b>Sorry an error occured:</b>" . nl2br($error);     return $error; } ?>[/code]
  6. YOu need to edit the php.ini to enable the mysql extension (php_mysql.dll). Have a read of [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]this FAQ[/url] in our  FAQ/Code Snippet Repository forum to see how to enable the extension. NOTE: if you have enabled the MySQL Improved extension (php_mysqli.dll) you'll want to enable the standard mysql extension (php_mysql.dll) too!
  7. There is no easy way I know of to run PHP4 and PHP5 simulataniously on a single Apache server. Apache2.0.x can work with PHP5 and PHP4 fine. Prehaps have a read of [url=http://devzone.zend.com/node/view/id/633]this tutorial/article[/url] over at zend.com. It tells you how to install PHP5 and PHP4 on one Apache server. This requires you to edit the host file - may need to boot into safe mode and login as administrator to edit this file Also if you wish to update PHP at any time, just download the zipped binaries package, then extract the contents of the zip to where PHP is installed to, you have upgraded PHP! Note if you have moved any PHP files to other location you will have to overwrite those files too with the newer updated files in the zip.
  8. I was playing GT4 last night did a big race, well the computer did it (B-Spec mode :)), As I went to exit from the race screen to collect my winnings something happens and the white loading icon for GT4 turns red! It was like that for about a miniute or so, I thought game had crash, very mad >:( So I reset the PS2 and the game doesnt load. Reset again and the same. I hear the PS2 spinning up the disk and the laser doing its work. And the drive stops spinning again. So I click the X button to go into the browser screen and I get a Disk Read Error message across the screen! I cannot play any disk on my PS2. Anyone else got this sort of error? There are fixes you can do yourself, which I am currently looking at. One fix is to clean the laser, or another is to change the angle of the laser when it reads the disk.
  9. Do you have fields named 1 throught to 19 in your scores table? Also prehaps see if there is an error with your query too, by adding or die(mysql_errro()) after mysql_query($sql) so it becomes: [code=php:0]mysql_query($sql) or die('Unable to perform query<br />' . mysql_error());[/code]
  10. [quote author=businessman332211 link=topic=108662.msg437381#msg437381 date=1158687271] Whether I use that right now or not, I am not sure, but the advice you gave me may prove invaluable.  So I always have a group of sessions for the user, so instead, I can create an array. like $_SESSION['userinfo'] = array( then create a inside the array for there username, email, ip address, last logged in date, and everything else.  Then if I have admin later I could do $_SESSION['admin'] = array then have all that in there then use temporary set's of session data for other things. So tehre would actually never be a need for get if this was true, so there has to be negatives to doing that, what negatives come with doing that, that you know of? if any. I like that idea [/quote] Nothing as far as I know of. Its still the same thing just that you are using an array.
  11. That is correct you cannot use a number as the variable name. Use a non numeric character first if want to use a number as a variable eg: $_1 = 'blah'; $_2 = 'blah';
  12. Businessman read the first post of this thread. What is happening is newline characters are being displayed in the posts for his forum as rn or r or n. Which mean the characters are being escaped.
  13. No it is bultin into the core of PHP. Did you try my suggestion by checking for any whitespace before and after [b]__HTML_END;[/b]. it is important nothing else is on the same line than __HTML_END;
  14. Also dont use words as your variables. Shorten them such as: sch for school cat for category scat for subcategory ps for post set. No need to make your variables so obvious to the user what they are. That you can do in your actuall code using comments. Additionally you might want to use mod_rewrite to tidy up your urls so its like this: site.com/schoolName/Category/subCategory/PostSet Or just use SA's suggesstion and use another method. Such as use a temporary session variables which holds an array of School name, category, sub cat etc, Eg: [code=php:0]$_SESSION['school_nav'] = array('sname' => 'SchoolNameHere', 'cat' => 'categoryName' ..etc..);[/code] Then use $_SESSION['school_nav']['sname'] to access the school name $_SESSION['school_nav']['cat'] to access the category etc. Use the power of arrays when dealling with masses of data dont create 1 session var for each variable. Use arrays to store multiple things in an session which relate to each other.
  15. I am. However it doesnt matter which version you use as PHP4 and PHP5 supports Heredoc syntax.
  16. Umm missed that! What code do you use to get the post out of the database when you display the post? The code you posted is fine. However I strongly suggesst you validate your user input. As at the moment your code is can be exploited with SQL Injection attacks, which can cause damage to your database!
  17. Code runs fine for me. Make sure you have no spaces or anyoyther text/whitespace before or after [b]__HTML_END;[/b]
  18. SieRobin have you posted your code yet which I requested? :)
  19. [quote author=SieRobin link=topic=108655.msg437336#msg437336 date=1158684227] Ehhh, I've never used var, my understanding was that "var" doesn't really exist in PHP. I just use $variablename and that distinguishes that it's a variable, [the dollar sign that is]. [/quote] When coding OO (Object Oriented) code you need to add var before the variable you are defining. The code posted above is fine regarding the var keyword. About putting a class inside another class PHP doesnt support this.
  20. Do you have a setting called [b]magic_quotes_gpc[/b] pr [b]magic_quotes_runtime[/b] or [b]magic_quotes_sybase[/b] enabled? If you do these could be why you are having this problem. Can you use .htaccess files with your hosting account? If you can create a new or edit existing .htaccess file in the root of where your forum is located and add this to it: [code]php_flag magic_quotes_gpc Off php_flag magic_quotes_runtime Off php_flag magic_quotes_sybase Off[/code] Also could you post the code you use when you submit the reply/thread to the database aswell as the code you use when you get the code out of the database too.
  21. Use window.status Eg: [code]<a href="javascript:void(0)" onMouseOver="window.status='Hello!'; return true" onMouseOut="window.status=''">Change Status Bar text!</a>[/code] However this isnt the a good way to display errors not many people take any notice of the status bar. Also most modern browsers dont allow for the staus bar text to be changed by defualt, however the user can change this by editing the browsers settings. For example in FF you need to goto Tools > Options > Content > Advanced button to the right of 'enable javascript' > Tick 'Change Status Bar Text'. In for FF to allow javascript to change the status bar text.
  22. Redarrow is correct. You cannot trigger any PHP code when you mouseover an object. PHP is parsed on the server and sends back the output. PHP and HTML cannot be ran together like you can with javascript. However I am little intreged how you managed to run PHP code onmouseover without using javascript. Could you post an example of your code.
  23. By defualt MySQL should have  set up a username which is root (which has no password set) during setup. You must have at least one user setup to access the MySQL database, this user will be the admin of the MySQL server. For your secound question yes. You'll want to open port 3363 in order for queries to be set to the database. Without the port being open PHP will not be able to send any requests to and from the MySQL database. Also as you are using a port that is not the defualt (3306) you'll need to tell PHP which port your MySQL server is running on. So you'll want to do something like this: [code=php:0]$conn = mysql_connect('localhost:3363', 'root', '') or die('Unable to connect to MySQL:<br />' . mysql_error());[/code] The number after 'localhost:' is the port number in which the mysql server is running on.
  24. As you are using floats, you will want to clear them So add [code]<br style="clear:both" />[/code] After: [code]<div id="footer">Copyright 2fr3sh Designs.2001-2006 </div>[/code] The border should now continue all theyw ay down to the footer.
  25. Here is my additon to Barands code: [code]<?php function calc_next($id) {     list($a, $b) = explode(' ', $id);     if ($b{1} == 'Z')     {         $b{1} = 'A';         $x = $b{0};         $x++;         $b{0} = $x;     }     for ($i = 1; $i <= strlen($b)-1; $i++)     {         $x = $b{$i};         $x++;         $b{$i} = $x;     }     return "$a $b"; } $next = 'D2 3WZ'; for ($i = 0; $i < 10; $i++) {     $next = calc_next($next);     echo $next . "<br />\n"; } ?>[/code] It'll, now change the last two letters. EDIT: Last two posts must of been made when I changing the code. SO prehaps this code may need to reworked again.
×
×
  • 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.