Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. If you want to show multiple results from database use a while loop ie: [code]while($row = mysql_fetch_array($result)) {     //echo out results }[/code]
  2. Both of these can be done with javascript. Have a look over at [a href=\"http://dynamicdrive.com/\" target=\"_blank\"]dynamicdrive.com[/a] for some scripts. Heres a [a href=\"http://dynamicdrive.com/dynamicindex16/requiredcheck.htm\" target=\"_blank\"]form validator[/a] and a [a href=\"http://dynamicdrive.com/dynamicindex16/maxlength.htm\" target=\"_blank\"]Maxlength script[/a] and [a href=\"http://dynamicdrive.com/dynamicindex16/limitinput.htm\" target=\"_blank\"]here is another[/a] - includes countdown
  3. Yes this would require a cron job to be setup if want to run a query/scrpt at certain time automatically.
  4. Yeah its only just happened today as I use it all the time in the PHP Freelancing forum. Prahaps Admins have chnaged something. I dont know strange. [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] [b]EDIT: Umm how strange it appears to be working fine now![/b]
  5. If you want to run your php scripts you need to store them in the folder that is viewable by the webserver, for WAMP it C:\wamp\www, then you go to [a href=\"http://localhost/filename.php\" target=\"_blank\"]http://localhost/filename.php[/a] You cannot run a php file like can with a html where you double click it and it opens up in your defualt web browser. Web browsers only understand client side code which is HTML, CSS and Javascript. It doesn't know what PHP is and so it displays it in the browser window. PHP is server side code and so requires a web server that has PHP installed on it inorder for the PHP code to be parsed.
  6. If you have WAMP installed then look for a folder called www in the root of the WAMP folder, C:\wamp\www You place all your documents in the www folder and then goto [a href=\"http://localhost/filename.php\" target=\"_blank\"]http://localhost/filename.php[/a] to run that file.
  7. Your PHP files will need to be in the folder in which the APache can see, them which is most probably the htdocs folder, C:\Program Files\Apache Group\Apache 2\htdocs by defualt unless you have stated otheriwse in the httpd.conf. When you goto [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] you should see a list of files and folders currently in your htdocs folder, if you dont but you are getting the Apache message clear the contents of the htdocs folder and you should now see a directory listing.
  8. By looks of things the folder that you are moving the uploaded file to doesnt have the correct permissions set, that is you are retrieving that error
  9. For some reason quick edit, inline editing of posts, comes up with the following error when using that feature: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Fatal error: Cannot break/continue 1 level (/home/www.phpfreaks.com/public_html/forums/sources/action_public/xmlout.php#235) in /home/www.phpfreaks.com/public_html/forums/index.php on line 511[/quote] Full edit mode works fine though.
  10. [b]Q:[/b] Whats does @ do? [b]A:[/b] When you browse peoples code you may have came across a weird bit of PHP syntax which has an @ symbol infront of a function or variable like so: [code]<?php $conn = @mysql_connect("localhost", "usr", "pass"); @mysql_select_db("foodb", $conn); ?>[/code] Ever wondered why and what it does? Well what the @ symbol does is supress errors, which means to force PHP to not show the error message. Why would you want to supress errors? You might not want any errors to be shown when your site goes live, such as if your database connection fails php will ouput an error message if error_reporting is turned You shouldn't really use the @ symbol, actually you should [b]never[/b] have to use it if you trap errors correctly it should always be the last option if all other methods of trapping errors fail. Such as for when connecting to mysql in the above code you can do this instead: [code]$conn = mysql_connect("localhost", "usr", "pass") or die("Error connecting to database");[/code] What that now does is trigger the [i]or die[/i] cluase, which will stop your script from running and display a simple error message that you have defined yourself, if php was unable to connect to mysql, therefore it doesn't show this nastly looking error message: [i]Access denied for user 'usr'@'localhost' (using password: YES)[/i] You usually see the @ symbol used by what I call [i]lazy[/i] PHP programmers. Hope that helps understand what the @ symbol does.
  11. [b]Q:[/b] Why do I get the headers already sent error mesage? [b]A:[/b] The reason why you are getting this message is beacuse you have may have/be:[list][*]Whitespace before the opening php tag <?php[*]Outputting something to the browser before you use session_start, header, setcookie etc[/list]session_start, setcookie, header and a few other functions write header information to the web server/browser what to do. Such as when you use session_start it requests the browser to create a cookie which stores the PHPSESSID. If you have output before you use these functions then they are unable to send new header information as it has already been sent in the form text/html, and so you get the headers already sent error message. You can easily find the source of the problem by looking at the error message.  As the answer is actully in there, but most people dont notice it as they may not understand what the error means. So lets take this error message as an example: [quote]Warning: Cannot modify header information - headers already sent by (output started at C:\server\www\test.php:6) in C:\server\www\test.php on line 8[/quote] Now PHP has given us a clue here as it has told use where the output has started! Have look where it says [b]output started at[/b] and it gives you the [b]full path to the file[/b] and the [b]line number[/b]. Now the line number that it stats is not usually where the output has started but where the output has ended, becuase the output could be above that line. So lets look at test.php: [code] 1 <html> 2 <head> 3 <title>Header test</title> 4 </head> 5 <body> 6 <?php 7 8 header("Location: http://www.google.com"); 9 10 ?> 11 </body> 12 </html>[/code] As you can see line 6 is the opening PHP tag (< ?php) this isn't the output but look above that line you'll notice it has some HTML code. This html code is the cause of the error! So when you get this error message again look for the clue where it says [b]output started at[/b] and goto the file and line number it says. Look above the line number and find where your output is located to. Hope that helps you understand why your are getting this error message. [b][color=red]EDIT: I found a useful website which explains how to use HTTP headers and common problems [url=http://www.expertsrt.com/tutorials/Matt/HTTP_headers.html]here[/url]. Very useful for people that dont understand headers.[/color][/b]
  12. Was you including PHP code in your post? If you was there is security script running on the server which will lcase that error message on some PHP functions, such when you want to post say the phpinfo function you need to do something like this: [code]<?php phpinfo (); //other functions: fopen (); fclose (); ?>[/code] Just add a space before the parenttheses
  13. I was actully going to mention that earlier, but I didn't.
  14. #wrapper is styling a html tag in your document that has an id of wrapper like this: [code]<div id="wrapper">somethiing here</div>[/code] Then in your css you can use this: [code]#wrapper {     font-sixe: 20px; /*Change font size*/ }[/code] With will change the font size of that div tag only. Usually web devs name a div tag the container or wrapper which holds all of the pages content, which then the developer uses css to center the site.
  15. You can place PHP code within the parentheses inside the exit function, or you can create a function which contains the code that you want to be run you call the exit function like so: [code]function exitFunc() {     // do something here, when you exit the script } exit(exitFunc());[/code] Does that help?
  16. Your SQL query is wrong. You are using count on the table name and not the table row. Your query should be this: [code]$qu="SELLECT COUNT(*) FROM member_messages WHERE id='$id'";[/code] If you want to use count on specific row do this: [code]$qu="SELECT *, COUNT(field_name) AS num FROM member_messages WHERE id='$id'";[/code] change where it says field_name with the actuall field name in your table. [b]Businessman[/b] SQL is forgiving if you use uppercase or lowercase for SQL keywords. I prefer to use uppercase with keywords in SQL queries.
  17. You can just use addslashes (when data is entered into the database) and stripslashes (when data is pullout of the database). addslashes will escape any double or single quotes in the data you have submitted automatically, and stripslashes does the opposite, which is remove the slashes addslashes added.
  18. To install IIS you'll want to follow [a href=\"http://www.webwizguide.com/asp/tutorials/installing_iis_winXP_pro.asp\" target=\"_blank\"]this tutorial[/a]. Also you will want to to choose IIS4 or 6 from the list when you run the PHP installer. Also you can check whether you have IIS installed and that it is running by going to [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] if a web directory is shown you either have IIS currently installed or another form of http server.
  19. You'll want to download http server, such as Apache or use MS IIS server, comes with XP Pro. Once you have apache or what every webserver setup you'll want to download the [b]zipped binaries[/b] package rather than the installer if you're using Apache, or use the installer for IIS. [b]NOTE: if you download Apache, make sure you download Apache2.0.x and not Apache2.2.x![/b] Now click this link to [a href=\"http://www.php.net/manual/en/install.windows.apache2.php\" target=\"_blank\"]configure Apache[/a] or this for an [a href=\"http://www.php.net/manual/en/install.windows.iis.php\" target=\"_blank\"]IIS Setup[/a].
  20. Rather than using two databasets, query two tables with one query! therfore you use just only one dataset, heres an example: [code]$sql = "SELECT t1.*, t2.* FROM table1_name t1, table2_name t2 WHERE t1.views = "4" && t2.views = "4" ORDER BY sort ASC"; $result = mysql_query($sql);[/code] Now you use a normal while loop [code]while($row = mysql_fetch_array($result)) {     echo "<tr><td class=\"lang\">$row['someIndex']</td><td class=\"Lang\">$row['someOtherIndex']</td></tr>"; }[/code]
  21. I am completly confused with this yur queries are exactly the same and I have no idea what you're trying to do. Could explain what you're trying to do and include an example too.
  22. To check the format of the data you might want to use preg_match which will check whether the date is in the correct format, heres a basic example: [code]<?php $date = "02/01/2006"; //valid //$date = "02/13/2006"; - invalid if(preg_match("/([0-9]{2})\/([0-12]{2})\/([0-9]{4})/", $date, $matches)) {     echo "Valid";     echo "<pre>" . print_r($matches, true) . "</pre>"; } else {     echo "not valid"; } ?>[/code] This code ONLY checks the format and not whether the date is valid, such as 31/02/2004 isnt a valid date but the format is correct. If you weant to check whether the data is valiud it'll require more tweeking.
  23. [quote]Why do I get the call to undefined function error message when connecting to mysql? How do I solve this? Whats wrong with PHP5?[/quote] If you have PHP5 and MySQL installed on Windows you may find that when you goto connect to mysql you'll get an error message like the following: [b]Fatal error: Call to undefined function mysql_connect() in [path of script here] on line [line number here][/b] Now this error may come as a suprise for some people that have migrated from PHP4 to PHP5 and immediately think PHP5 is broken. This is not the case. In actual fact there has been a license change between PHP and MySQL. PHP no longer embeds MySQL support into PHP as of PHP5. Instead what you need to do is simply enable the mysql extension. Once you've done that you'll be able to use any of the mysql functions within PHP. Okay first locate your php.ini file which is most probably located in either the windows folder (C:\WINDOWS), the system folder (C:\WINDOWS\SYSTEM32), or in your php folder. If it isn't in any of those folders simply do a quick search for it, if windows still cannot find it chances are you haven't created it yet. To do so simply goto your php installation folder (C:\php, defualt path) and find a file called [b]php.ini-recommended[/b] now copy this to the Windows folder and rename it to just php.ini. Once you have found your php.ini file, open it and find the following line: [code]extension_dir = "./"[/code] change this line to the following: [code]extension_dir = "C:\php\ext"[/code] What this line does is tells PHP where all your PHP extensions are located to. [b]NOTE: Change C:\PHP to the actuall path of your PHP folder if it is not located in the root of the hard drive, I used this as by defualt PHP is extracted/installed there[/b] Now scroll down abit further and find the following line: [code];extension=php_mysql.dll[/code] remove the semi-colon from infront of that line to enable the mysql extension. Once you have done that save your php.ini and restart your server. When you goto use mysql_connect() again you shouldn't get any errors. If you do get an error when you restart your server or use the mysql_connect function then make sure you have configured the path of the php extension folder and that you have successfully restarted the sercer correctly. Also make sure you have copied a file called [b]libmysql.dll[/b] to the windows folder too. Once you have copied the file restart your sever again. This should now enable mysql support. If you get no errors when you connect to mysql through php then you have successfully enabled the mysql extension! I hope this has solved your problem with connecting to mysql with PHP5. Also this FAQ can be used to enable mssql, msql and other database extensions too!
  24. IPB does have the option to change your display name but that feature is not enabled on this forum currently. end of discussion now?
  25. 2 - about accessing the httpd.conf file most web hosts dont allow access to this file unless your client is on a dedicated server. You should use httaccess for what you want to do, if the web host allows the use of htaccess, not all do. 12 - The problem with webhosts is they insist on allowing backward compatibily which means very few hosts will make the move to PHP5 or switch of register_globals, there are still hosts out there running PHP3! and the majority of web hosts use PHP4. 14 - isset and empty are completly different. isset checks the instance of the variable, it does not check the value of the variable. empty on the otherhand checks the value of the variable and not the instance of the variable. 16 - yes there is going to be a new version of PHP6 but it wont be available until 2008 most likely. PHP6 will basically be a recode just like PHP5 was, Also register globals will be a thing of the past.
×
×
  • 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.