2 questions.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

2 questions.

Post by William »

Code:

Code: Select all

<?php
if ( $title == "" || $by == "" || $email == "" || $body == "" ) {
		Print "We are sorry, You did not fill in all fields.";
	} Else { 
		$filename = "db.php";
		$fp = fopen( $filename, "w" ) or die("We are sorry, You can not add the post. Please contact TheNetherRealm - Web Design. For more information.");
		fwrite( $fp, "
		<table width="75%" border="0">
  <tr> 
    <td><font color="#00FF00">$title</font></td>
  </tr>
  <tr> 
    <td bgcolor="#00CC00"><p><font color="#000000">$body</font></p></td>
  </tr>
  <tr> 
    <td align="right" bgcolor="#00CC00"><font color="#FFFFFF">&nbsp;</font><font color="#000000">Posted 
      by</font> <font color="#000000"><a href="$email" class="post">$by</a></font></td>
  </tr>
</table>include("db.php");		
		" );
		fclose( $fp );
	}
?>
Does anyone know how that include i can make it include the text in it? I know there is a command like ."". or somthing just dont know what it is :'( (I am a newb as you can tell sigh...) && is it possible to put a php.ini in your cgi-bin and it will over-ride the servers and if not how can i?
Thanks - William
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

Code: Select all

"</table>".include("db.php");

although this isn't gonna do anything.. you should probably call the include above all your other code, and then call whatever variables it is out of it that you want where the include is currently.


edit, so you would want to do it like this :

Code: Select all

<?php 

include("db.php");

if ( $title == "" || $by == "" || $email == "" || $body == "" ) { 
      Print "We are sorry, You did not fill in all fields."; 
   } Else { 
      $filename = "db.php"; 
      $fp = fopen( $filename, "w" ) or die("We are sorry, You can not add the post. Please contact TheNetherRealm - Web Design. For more information."); 
      fwrite( $fp, " 
      <table width="75%" border="0"> 
  <tr> 
    <td><font color="#00FF00">$title</font></td> 
  </tr> 
  <tr> 
    <td bgcolor="#00CC00"><p><font color="#000000">$body</font></p></td> 
  </tr> 
  <tr> 
    <td align="right" bgcolor="#00CC00"><font color="#FFFFFF"> </font><font color="#000000">Posted 
      by</font> <font color="#000000"><a href="$email" class="post">$by</a></font></td> 
  </tr> 
</table>".$some_var_from_db_php_here); 
      fclose( $fp ); 
   } 
?>
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Cant.

Post by William »

db.php is nothing but HTML. lol. No varibles to it hmm... so any other ideas? Thanks
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Ok i figured it out!

Post by William »

when yuor right it i should just pur r+ sorry. Found on another post guess i really payed attentions huh lol and thanks alot :-)
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

try this:

Code: Select all

<?php 
if ( $title == "" || $by == "" || $email == "" || $body == "" ) { 
      Print "We are sorry, You did not fill in all fields."; 
   } Else { 
      $filename = "db.php"; 
      $filecontent = file("db.php");
      $fp = fopen( $filename, "w+" ) or die("We are sorry, You can not add the post. Please contact TheNetherRealm - Web Design. For more information."); 
      fwrite( $fp, " 
      <table width="75%" border="0"> 
  <tr> 
    <td><font color="#00FF00">$title</font></td> 
  </tr> 
  <tr> 
    <td bgcolor="#00CC00"><p><font color="#000000">$body</font></p></td> 
  </tr> 
  <tr> 
    <td align="right" bgcolor="#00CC00"><font color="#FFFFFF"> </font><font color="#000000">Posted 
      by</font> <font color="#000000"><a href="$email" class="post">$by</a></font></td> 
  </tr> 
</table>$filecontent      
      " ); 
      fclose( $fp ); 
   } 


?>
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

R+ or W+?

Post by William »

Wow im confused i guesss il try both ways :-D amazing my book didnt show all of this hmm
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

Both ways should work. You prolly got the r+ command from this thread http://www.devnetwork.net/forums/viewtopic.php?t=14963 as well where we talked about it ;)
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

R+ wont work and either will W+

Post by William »

I don't get I I tryed it both ways here is the code.

Code: Select all

<?php
if ( $title == "" || $by == "" || $email == "" || $body == "" ) {
		Print "We are sorry, You did not fill in all fields.";
	} Else { 
		$filename = "db.php";
		$fp = fopen( $filename, "r+" ) or die("We are sorry, You can not add the post. Please contact TheNetherRealm - Web Design. For more information.");
		fwrite( $fp, "
		<table width="75%" border="0">
  <tr> 
    <td><font color="#00FF00">$title</font></td>
  </tr>
  <tr> 
    <td bgcolor="#00CC00"><p><font color="#000000">$body</font></p></td>
  </tr>
  <tr> 
    <td align="right" bgcolor="#00CC00"><font color="#FFFFFF">&nbsp;</font><font color="#000000">Posted 
      by</font> <font color="#000000"><a href="$email" class="post">$by</a></font></td>
  </tr>
</table>
		" );
		fclose( $fp );
	}
?>
Post Reply