Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Something is being outputted on line 3 in test.php. As this where PHP has detected where the output has started: [quote]Warning: Cannot modify header information - headers already sent by ([color=red][b]output started at /home/lov3dco/public_html/test.php:3[/b][/color]) in /home/lov3dco/public_html/test.php on line 24[/quote] Note the bit in bold above. Thats the important bit you want to read.
  2. Something like this: [code]<?php $file = file_get_contents('file.toc'); // find the ## Title: line preg_match("/## Title:(.*+)/i", $file, $matches); // debug see the matches found // echo '<pre>' . print_r($matches, true) . '</pre>'; // the version: $version = $matches[1]; echo "The version/name of this script is: $version"; ?>[/code] Should work. It finds ## Title: and returns whats after that.
  3. You can do relative filepaths to a file you want to include. But if the file you are including is including other files. Then PHp wont use the relative path for the included file but the file that is including the file. As with require or include PHP basically gets the contents of the file and pastes where it is being including to.
  4. Use file_get_contents then eregi or preg_match to get MonkeyQuest v2.3.1
  5. Businessman what king arthur ment was it doesnt matter how much space you have between <?php and session_start();, but what does matter is the space before the opening <?php tag. Any whitespace after <?php is not outputted to the browser, unless you are echo/print'ing it.
  6. That is becuase the secound require_once is using a ralative path to the first file and not relative to the secound file. A way around this to pre-pend $_SERVER['DOCUMENT_ROOT'] to the path like so: [code]require_once $_SERVER['DOCUMENT_ROOT'] . '/somefile.php';[/code]
  7. Its your forum rank. It means nothing really. Your rank will change when your post count goes up. I think you'll get four stars when you get to 300 for your post count. I'm not sure how many post each rank requires.
  8. This is better, added a bit of data validation. [code=php:0]if(empty($_GET['id']) || !is_numeric($_GET['id'])) {   echo "The data provide is either invalid or was not specified."; }[/code]
  9. You can download a package called WAMP, just search it in google, or XAMPP. Both the samething but different packages. However if you to do a manual install I would recommend to download Apache2.0.5x (msi package) from httpd.apache.org and PHP5.1.x (zipped package) from php.net use the guide posted above by hostfreak to see how to install these.
  10. You need to enable the mysql extension, read [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]this thread[/url] to enable the mysql extension. Ignore the stuff about Apache.
  11. Use a foreach loop: [code=php:0]// loop through the $row array, setting up the sessions vars automatically. foreach($row as $key => $value) {     $_SESSION[$key] = $value; }[/code] Make sure you have session_start(); as the first line in permission file, in order for the session variables to populate. EDIT: Come to think of it you might not need a foreach loop, instead your can just do this: [code=php:0]$_SESSION = mysql_fetch_array($r);[/code]
  12. This shoud display all contents from the users table: [code=php:0]<?php // connect to database here $conn = mysql_connectr('localhost' 'username', 'password') or die('Unable to connect to MySQL ' . mysql_error()); // select our database mysql_select_db('zyco_zycologin', $conn); // setup our query: $sql = 'SELECT * FROM users ORDER BY username ASC'; // perform our query: $result = mysql_query($sq, $conn) or die("Unable to perform query $sql<br />" . mysql_error()); // start our table echo '<table border="0" cellpadding="0" cellspacing="0" width="90%" align="center"> '; // show contents of database: while($row = mysql_fetch_assoc($result)) {     // echo each field in the database     echo '<tr><td>' . implode('</td><td>', $row) . "</td></tr>\n"; } // close our table: echo '</table>'; ?>[/code] Have a read of the comments if you are unsure.
  13. I find it easier to use a function called [url=http://uk.php.net/manual/en/function.preg-replace-callback.php]preg_replace_callback[/url] when doing PHP BBCode parsers. Heres a quick demo: [code]<?php function bbcode($txt) {     // bbcodes     $bbcodes = array( "|\[b\](.+)\[/b\]|is",                       "|\[u\](.+)\[/u\]|is",                       "|\[i\](.+)\[/i\]|is"                     );     // html     $replace = array( "<strong>$1</strong>",                       "<u>$1</u>",                       "<em>$1</em>"                     );     $text = preg_replace($bbcodes, $replace, $txt);     // call a dedicated function to parse our PHP BBCodes:     $text = preg_replace_callback("#\[php\](.*?)\[\/php\]#is", 'doPHP', $text);     return nl2br($text); } // our dedicated PHP BBCode function function doPHP($matches) {     #echo '<pre>' . print_r($matches, true) . '</pre>';     //highlight PHP Code     $php = highlight_string($matches[0], true);     // remove the mataches     unset($mataches);     // remove the php BBCodes     $php = preg_replace("#(\[php\]|\[/php\])#i", "", $php);     //clean up spaces and extra line breaks     $php = str_replace('&nbsp;&nbsp;', '&nbsp; ', $php);     $php = str_replace('<br />', '', $php);     return $php; } $str = "[code=php:0]<?php echo 'hello world'; if(\$var == 'hello world') {     echo 'true'; } ?>[/code]"; // call the bbcode parser function. $str = bbcode($str); echo $str; ?>[/code]
  14. [quote author=gijew link=topic=102502.msg406858#msg406858 date=1154386656] This isn't perfect but... if (preg_match('/^[0-9a-zA-Z]+$/i', $_POST['FieldName'])) {   echo 'matches'; } else {   echo 'no match'; } [/quote] if you have the i modifier, you dont need the a-z bit in the expression gijew. So the expression can be just: [code]/^[0-9A-Z]+$/i[/code]
  15. You are going to http://localhost/ and then clicking on the file you want to run? If you are and its opening up within notepad then Apache appears to bemisconfigured. How have you configured Apache to parse PHP files with the PHP Intepreter? What tutorial did you follow to install Apache, PHP and MySQl.
  16. Yeah if you want to view how your design looks when you click the world icon within DW and its a PHP file, it'll ask you those questions again. However you can run the code through PHP Designer if you have WAMP installed and have PHP Designer setup to point to the PHP Intepreter, all shown on the first video of that site linked above. [quote]if not will it be viewable once i put it in the ftp server?[/quote] No, if you run through that first video again on that site. It'll show you how to install a package called WAMP. WAMP is a web server package that you can install your PC. Once you have installed that you can save your files within the htdocs folder of the WAMP package and then go to http://localhost/filename.php to run your PHP scripts.
  17. [quote author=pixy link=topic=102382.msg406645#msg406645 date=1154370359] Not all servers support $_SERVER['HTTP_REFERER']...either that or it has to do with the browser, which may choose not to send refering information. [/quote] Yeah its to do with the browser. Some browsers do some dont. Also it can be easily fooled too.
  18. Yeah. But you can still use PHP designer to design the polls. You can use any app you want to you. But with dreamweaver you cannot preview how the page looks if you have PHP in it. If you want to preview the PHP code, you'll want to setup a project within dreamweaver to setup a local testing server etc.
  19. Change this: [code]<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/$name.exe \" />[/code] to: [code]<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net/programs/{$name}.exe \" />[/code]
  20. You can use any app you want to develope your PHP scripts with, however phpdesigner 2006 is a lot easier to setup, compared to Dreamweaver. Also PHP Designer 2006 is deigned towards PHP, as iut has features for debugging your PHP scripts with etc.
  21. Yeah you can delete the project if you dont want it, Just goto Site > Manage > Select Sample and click the delete/remove button on the right. NOTE you may be in the Avanced view while editting that project. Select the Simple tab in Edit projects properties window.
  22. Did you use my suggestion, usoing the full PHP opening tag - <?php Looking at that guide it is a little old. I suggest you do the following to configure Apache with PHP. First find the httpd.defualt.conf file. Now rename this to httpd.conf to overright the existing httpd.conf file. Now you have reset the config file back to defualt. Find this: [code]#LoadModule ssl_module modules/mod_ssl.so[/code] Add the following after it: [code]LoadModule php5_module "C:/php/php5apache2.dll" PHPIniDir "C:/WINDOWS"[/code] If you have PHP4, use this instead of the php5_module line: [code]LoadModule php4_module "C:/php/isapi/php4apache2.dll"[/code] Now scroll down and find the following: DirectoryIndex and add index.php to the end of the list, making sure you add a space between the last entry in the list, like so: [code]DirectoryIndex index.html index.html.var index.php[/code] Now find the following: [code]AddType application/x-gzip .gz .tgz[/code] now add the following after it: [code]AddType application/x-httpd-php .php .phtml AddType application/x-httpd-phps .phps[/code] Now save the httpd.conf file. Find the php.ini file and move it to C:\WINDOWS if you haven't done so already. Now restart Apache Server. If Apache starts with no beeps or errors appearing. Then Apache has been configured to parse PHP files with the PHP Intepreter. Now try running your php file again.
  23. Use HTML comment tags: [code]<!-- comment here -->[/code]
  24. PHP can force a redirect with the header function: [code]header("Location: index.php");[/code] Make sure you have session_start(); at the top of everypage that uses sessions.
  25. Prehaps you'll want to fetch the contents of the file first. Then use str_replace to remove </log> then you add it back in with file_put_contents like so: [code=php:0]$xmld = file_get_contents($file); $xmld = str_replace('</log>', '', $xmld); file_put_contents($xmld . $file . '</log>', $log->asXML())[/code]
×
×
  • 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.