Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. [quote author=steelmanronald06 link=topic=107099.msg429701#msg429701 date=1157602315] That could be possible. just having an if statement grab the current url, match it to a predefined url, if it matches throw the image up.  I will discuss this more with ober. It would take all 1 hour or less to accomplish, and i think would really be cool to add.  thanks for the input.  i will post back with what we decide on. [/quote] Actualy Steelman you dont need to do that, I think you can just assign different themes/templates to individual forums if you wanted to. So if you want the MySQL forum to have the mysql freaks header graphic just setup a new theme/template for that forum.
  2. No one can see the source code of any php file. If you can see the source code (not the output) when you go to view > source code, or when you go to the file itself. Then your server is misconfigured. The only time some will be able to see the source is if they manged to reteive your FTP details and download the file via FTP. Or if your server is configured to show the source code highlighted if you use a .phps extension.
  3. There is no set guidelines to how PHP code should be formated AFAIK. Its mainly down to the personal preference of the programmer. However if developing a script with a group of other programmers and they all have a different styles of coding, then there should be guidelines set out for developers to follow when programming the web application, to help keep the code clear and readable. As long as the code is clear and readable to anyone that sees it then it doesnt matter what style you format your code.
  4. You'll have to scan the directory manually using opendir and readdir.
  5. [quote author=quillspirit link=topic=107001.msg429344#msg429344 date=1157561387] It is important that you don't have any kind of output before session_start(); - except for coments. A space between php open and session_start(); will killl you. correct: [code] <? session_start(); session_destroy(); ?>[/code] Incorrect: [code] <? session_start(); session_destroy(); ?>[/code] [/quote] Thats is not a valid example as this will work [code] <? session_start(); session_destroy(); ?>[/code] It wont work if there is output before you use session_start. Any whitspace between <?(php) and ?> will not be outputed and so you can put as much whitespace as you like within those tags. The only time when php will display the headers already sent error is when there is some form of outpu, eg whitespace, text/html before your use any header realted functions.
  6. Yeah I agree with roopurt18, however I prefer 4 spaces rather than two for a tab, and i like my curly braces to be on thier own line, eg: [code=php:0]// Define consts define('CONST1', 'VAL01'); define('CONST2', 'VAL02'); // This class does blah blah yadda yadda // Use for asdf qwerty class MyClass extends MyBase {     function MyClass()     {         // comment         $var = $val;         if(isset($something))         {             // comment             // comment             $hello = $world;         }         return true;     } }[/code] IMO it makes the code more readable, and you can tell where your code blocks start and end, where as if the opening curly brace isn't on its own you can only see where the code block ends. It also makes it easier to pair up the curly braces too.
  7. session_destory will kill a session.
  8. Oops missed out the semi-colon after this: Change: $Username = $_POST['txtLogInUserName'] to this: $Username = $_POST['txtLogInUserName'];
  9. You mean this code: [code=php:0]echo "Logged In As: ".$Username;[/code] Thats fine. Whats wrong with it.
  10. Okay so the cause is with phpMyAdmin now then make sure you have extracted the contents of the phpMyAdmin contents properly and that you have [url=http://www.phpmyadmin.net/documentation/#setup]setup the config.inc.php[/url] file correctly. Also make sure you have the latest statble release of [url=http://www.phpmyadmin.net]phpMyAdmin[/url] Also the MySQL configuration reported is fine.
  11. Try this: [code=php:0]function strip($domain) {     // get the segments of the url into an array     // http://php.net/parse-url - for more info     $url = parse_url($domain);     $domain = str_replace("www.", "", $url['host']);     return $domain; } echo strip('http://www.domain.com'); [/code]
  12. Try changing the port that Apache is listening to, such as try port 8888. So find Listen 80 in the httpd.conf change 80 to 8888 save the httpd.conf. Restart Apache. Now goto http://localhost:8888 any difference? You ping localhost on your computer, by going to Start Run > type in cmd. Click Ok now type in [b]tracert 127.0.0.1[/b].
  13. [quote author=Barand link=topic=107057.msg429082#msg429082 date=1157538819] Is nesting of function definitions now permitted? I thought it was a no-no in PHP. Or am I reading that mess of code incorrectly? [/quote] You've always been able to nest functions in PHP AFAIK. To call nested function you first have to call the function that is containing the nested functiont first, then you can call the nested function. Example: [code=php:0]function foo() {     echo 'foo<br />';     function bar()     {         echo 'bar';     } } // call parent function foo(); // now call nested function bar();[/code]
  14. If you want to include parts of the file, you'll want to seperate your code into functions, for example. You have a form. You put all the code for the form in a function called showForm, like so: [code=php:0]// define the function showForm function showForm(); {     // we echo the HTML for the form     // Below is HEREDOC syntax     echo <<<HTML <form action="file.php" method="post">   your form fields here </form> HTML; // DO NOT INDENT OR PUT ANYTHING ON THE LINE ABOVE }[/code] Now to call the function you use: [code=php:0]showForm();[/code] When you call this function, it'll produce this: [code]<form action="file.php" method="post">   your form fields here </form>[/code] Which will allow for reusable code.
  15. You dont close the constructor (Omega function) in your class: [code]function Omega() { } // <-- missing closing brace.[/code]
  16. When you changed the php.ini you did restart the server. It is important that you restart the server if you have changed any configuration files.
  17. When calling the function it should be this: [code]echo strip('www.domain.com');[/code] Otherwise PHP will try to find the constants www, domain and com and join them to gether. When using a string it must be in quotes. Also I have modified your title, please try to use descriptive titles when posting threads.
  18. What port is Apache running on, look for the Listen directive, after that should be the port number it is using. If its not port 80. You'll need use this to access your intranet: 127.0.0.1:port_number or just localhost:port_number - eg http://localhost:8080/ if 8080 is what Apache is configured to use that port. Also PHP isnt compatible with Apache2.2.x. You'll need to download thirdparty PHP modules to get PHP to work with Apache2.2. You can get the modules over at apachelounge.com. Anb eaiser option is to down grade Apache to Apache 2.0.x PHP is currently only compatible with Apache 1.3.x and Apache 2.0.x. The next release of PHP should support Apache 2.2.x.
  19. Post yor exact code here from index.php. When doing so please use the the code tags  - [nobbc][code]your code here[/code][/nobbc]
  20. man your site is wierd. Try this: [code]<?php session_start(); $session = session_id(); $db_name = "db175253437"; $conn = mysql_connect("db491.perfora.net", "dbo175253437" ,"**********", true) or die("Couldn't connect"); mysql_select_db($db_name, $conn) or die("Couldn't select Database1."); $itemID = $_POST['itemID']; $sql = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'"; $result = mysql_query($sql, $conn) or die("Unable to run query - <code>{$sql}</code><br />" . mysql_error($conn)); if(mysql_num_rows($result) == 1) {     $row = mysql_fetch_assoc($result);     $image = str_replace(" ", "", $row['itemName']);     $itemName1 = $row['itemName']; } else {     die("Item Id " . $itemID . " was not found"); } ?> <html> <head> <title><?php echo $itemName1; ?></title> </head> <body> <BR> <table width="227" border="0" cellspacing="0" cellpadding="0" height="104" style="border-collapse: collapse" bordercolor="#111111">   <tr>     <td height="104" valign="top" width="227" bordercolorlight="#000080">       <table width="200" border="1" cellspacing="0" cellpadding="0" bgcolor="#6699FF" bordercolor="#000066">         <tr>           <td align=center>             <table width="200" border="0" cellspacing="0" cellpadding="0">               <tr align=center bgcolor="blue">                 <td>                   <font face="Arial, Helvetica, sans-serif" size="3" color="white"><b><?php echo $itemName1; ?></b></font>                 </td>               </tr>               <tr bgcolor="#FFFFFF" align="center">                 <td><img src="../images/items/<?php echo $image; ?>.jpg"></td>               </tr>             </table>           </td>         </tr>       </table>       <BR>       <table width="205" border="1" cellspacing="0" cellpadding="0" bordercolor="#000099">         <tr>           <td>             <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">               <tr bgcolor="#FFCCFF">                 <td height="20" colspan="2" bgcolor="#0000FF" bordercolor="navy">                   <div align="center">                     <font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Item Info:</b></font>                   </div>                 </td>               </tr>               <tr>                 <td width="99" height="10" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Type:</font>                 </td>                 <td width="101" height="10" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1"><?php echo $type; ?></font>                 </td>               </tr>               <tr>                 <td height="19" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1">Use:</font>                 </td>                 <td height="19" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1">&nbsp; </font>                 </td>               </tr>           </table>         </td>       </tr>     </table>     <br>     </td>   </tr> </table> </body> </html>[/code] If it dont show the name I dont know. :(
  21. You have commented out the closing } for the first if statement. So change: [code]//}  else { // echo "Redirecting to homepage:::  NOTE TO SELF: ADD REDIRECTION"  ; // }[/code] To this: [code]} // this closes the first if statement //  else { // echo "Redirecting to homepage:::  NOTE TO SELF: ADD REDIRECTION"  ; // }[/code]
  22. You have coded it to do that. What you'll want to do is change [code=php:0]$spacedname = str_replace(" ", "%20", $row['itemName']);[/code] to: [code=php:0]$itemName = $row['itemName'];[/code] Now find [code]<font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $spacedname; ?></b></font>[/code] Change that to this: [code]<font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $itemName; ?></b></font>[/code]
  23. You havnt started the sessions thats why. When ever you need to use session variables you need have session_start(); before you use any sessions, otherwise the sessions wont work. [code=php:0]<?php // MUST START THE SESSION FIRST // BEFORE USING ANY SESSION VARIABLES session_start(); if (isset($_SESSION['username'])) {     echo 'Welcome, ' . $_SESSION['username']; } else {     echo "Welcome to my website!"; } ?>[/code]
  24. The code is now working! For some reason it wasnt connecting to the database when you was including config3.php So all you need to do now is put in the relevent HTML/PHP code in to display the page correctly. Which I think is this: [code]<?php session_start(); $session = session_id(); $db_name = "db175253437"; $conn = mysql_connect("db491.perfora.net", "dbo175253437" ,"**********", true) or die("Couldn't connect"); mysql_select_db($db_name, $conn) or die("Couldn't select Database1."); $itemID = $_POST['itemID']; $sql = "SELECT * FROM myitemschibi WHERE itemID ='$itemID'"; $result = mysql_query($sql, $conn) or die("Unable to run query - <code>{$sql}</code><br />" . mysql_error($conn)); if(mysql_num_rows($result) == 1) {     $row = mysql_fetch_assoc($result);     $image = str_replace(" ", "", $row['itemName']);     $spacedname = str_replace(" ", "%20", $row['itemName']); } else {     die("Item Id " . $itemID . " was not found"); } ?> <html> <head> <title><?php print $itemName; ?></title> </head> <body> <BR> <table width="227" border="0" cellspacing="0" cellpadding="0" height="104" style="border-collapse: collapse" bordercolor="#111111">   <tr>     <td height="104" valign="top" width="227" bordercolorlight="#000080">       <table width="200" border="1" cellspacing="0" cellpadding="0" bgcolor="#6699FF" bordercolor="#000066">         <tr>           <td align=center>             <table width="200" border="0" cellspacing="0" cellpadding="0">               <tr align=center bgcolor="blue">                 <td align=center bgcolor="blue">                   <div align="center">                     <font face="Arial, Helvetica, sans-serif" size="3" color="blue"><b><?php print $spacedname; ?></b></font>                   </div>                 </td>               </tr>               <tr bgcolor="#FFFFFF" align="center">                 <img src="../images/items/<?php echo $image;?>.jpg">                 <br>               </tr>             </table>           </td>         </tr>       </table>       <BR>       <table width="205" border="1" cellspacing="0" cellpadding="0" bordercolor="#000099">         <tr>           <td>             <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">               <tr bgcolor="#FFCCFF">                 <td height="20" colspan="2" bgcolor="#0000FF" bordercolor="navy">                   <div align="center">                     <font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Item Info:</b></font>                   </div>                 </td>               </tr>               <tr>                 <td width="99" height="10" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1">&nbsp;Type:</font>                 </td>                 <td width="101" height="10" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1"><?php print "$type"; ?></font>                 </td>               </tr>               <tr>                 <td height="19" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1">Use:</font>                 </td>                 <td height="19" bordercolor="navy">                   <font face="Arial, Helvetica, sans-serif" size="1">&nbsp; </font>                 </td>               </tr>           </table>         </td>       </tr>     </table>     <br>     </td>   </tr> </table> </body> </html>[/code]
  25. Use something like this: [code=php:0]if (isset($_SESSION['Username']) && $_SESSION['accessleve'] >= 1) {     echo 'Welcome, ' . $_SESSION['Username']; }[/code] Make sure you  have session_start(); before you use any $_SESSION variables.
×
×
  • 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.