Jump to content

specialguy

Members
  • Posts

    35
  • Joined

  • Last visited

Posts posted by specialguy

  1. Here's the error i'm getting : Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/hellkrea/public_html/version3/site/news.php on line 34 Here's the news.php page :

    <? function News() {   if (!isset($_GET['do']))   { 	$local_file = 'news.nfo'; 	$file = fopen($local_file , 'r') or die("Couldn't open first place");   	while (!(feof($file))) 	{ 	$news[] = fgets($file, 1000); //Slap each line upto 1000 chars into an array 	} 	 	$servertime = time(); 	echo date("H:i:s, d M, Y", $servertime) . "rn<br>"; 	    $numitems = count($news); 	 	echo "Count : $numitems<br>rn"; 	 	for($x=0; $x < $numitems; $x++) 	{ 	  echo $news[$x] . "<br>"; 	} 	 	echo "<a href=" . $_SERVER['PHP_SELF'] . "?do=new>Add News</a>n";    	fclose($file);   }   elseif ($_GET['do'] == "new")   { 	echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . "?do=add">n" .  		  "Author<br>" .  //  THIS WOULD BE LINE 34.		  '<input type="text" size="15" name="author"><br>' .  		  "News to add :<br>n" .  		  '<textarea rows="20" cols="60" name="new_news">' . 		  '</textarea><br>' .  		  '<input type="submit" name="submit" value="Add News"><br>' .  		  '</form>';   }      elseif ($_GET['do'] == "add")    { 	$time = time(); 	$read_time = date("H:i:s, d M, Y", $time); 	$unstripped_news = $_POST['new_news']; 	$new_news = stripslashes($unstripped_news); 	$author = $_POST['author']; 	$fpnews = fopen('news.nfo', 'r'); 	$old_content = fread($fpnews, filesize('news.nfo')); 	$fp = fopen('news.nfo', 'w'); 	fwrite($fp, "rn$timern$authorrn$new_newsrn$old_content", (strlen($time) + strlen($new_news) + strlen($author) + strlen($old_content) + 16)); 	echo "News added successfully. Here is what you posted.<br>n" .  		 "Submitted on $read_time<br>n" .  		 "By : $author <br>n" . 		 "News : <br> n$new_news <br> n"; 		  	echo "Back to <a href=" . $_SERVER['PHP_SELF'] . ">news</a>";    fclose($fpnews); 	fclose($fp);   } echo "n<br>n<a href=" . "/news.php" . "s>View my Source!</a>"; echo "n<br>n blah blah blah <a href=news.nfo>news.nfo<a/> : " . filesize('news.nfo'); } ?>

    Thanks for u help

    Here's the error i'm getting : Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/hellkrea/public_html/version3/site/news.php on line 34 Here's the news.php page :
    <? function News() {   if (!isset($_GET['do']))   { 	$local_file = 'news.nfo'; 	$file = fopen($local_file , 'r') or die("Couldn't open first place");   	while (!(feof($file))) 	{ 	$news[] = fgets($file, 1000); //Slap each line upto 1000 chars into an array 	} 	 	$servertime = time(); 	echo date("H:i:s, d M, Y", $servertime) . "rn<br>"; 	    $numitems = count($news); 	 	echo "Count : $numitems<br>rn"; 	 	for($x=0; $x < $numitems; $x++) 	{ 	  echo $news[$x] . "<br>"; 	} 	 	echo "<a href=" . $_SERVER['PHP_SELF'] . "?do=new>Add News</a>n";    	fclose($file);   }   elseif ($_GET['do'] == "new")   { 	echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . "?do=add">n" .  		  "Author<br>" .  //  THIS WOULD BE LINE 34.		  '<input type="text" size="15" name="author"><br>' .  		  "News to add :<br>n" .  		  '<textarea rows="20" cols="60" name="new_news">' . 		  '</textarea><br>' .  		  '<input type="submit" name="submit" value="Add News"><br>' .  		  '</form>';   }      elseif ($_GET['do'] == "add")    { 	$time = time(); 	$read_time = date("H:i:s, d M, Y", $time); 	$unstripped_news = $_POST['new_news']; 	$new_news = stripslashes($unstripped_news); 	$author = $_POST['author']; 	$fpnews = fopen('news.nfo', 'r'); 	$old_content = fread($fpnews, filesize('news.nfo')); 	$fp = fopen('news.nfo', 'w'); 	fwrite($fp, "rn$timern$authorrn$new_newsrn$old_content", (strlen($time) + strlen($new_news) + strlen($author) + strlen($old_content) + 16)); 	echo "News added successfully. Here is what you posted.<br>n" .  		 "Submitted on $read_time<br>n" .  		 "By : $author <br>n" . 		 "News : <br> n$new_news <br> n"; 		  	echo "Back to <a href=" . $_SERVER['PHP_SELF'] . ">news</a>";    fclose($fpnews); 	fclose($fp);   } echo "n<br>n<a href=" . "/news.php" . "s>View my Source!</a>"; echo "n<br>n blah blah blah <a href=news.nfo>news.nfo<a/> : " . filesize('news.nfo'); } ?>

    Thanks for your help

  2. Nono, here an exemple :Option 1(Are you over 18 or less than 18?)so depending if you choose over 18 in option 1 or less than 18,the option 2 that is ALREADY THERE will show all ages over 18 or all ages that are lower than 18.I hope that helped you understanding my poor english. THanks alot for helping me man.

  3. I really need you guys for a project im doing. so here it is, I'm doing a PHP script that needs some Javascript to show listbox when selecting a choice.So here it is, the guy select something between the couples of choice and then a listbox appear and he can select something else.I really don't know how to do it and I know it isn't long so please could someone help me doing it? or simple gimme some link where there's exemple of it.Thanks alot !

  4. Dunno if you still want an exemple of Div/css but here it is :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title></title><style type="text/css"><!--body {  margin: 0px;  padding: 0px;}#header {  background: #0f0;  width: 100%;}#leftcol {  background: #f00;  float: left;  width: 20%;  height: 500px;}#rightcol {  background: #f00;  float: right;  width: 20%;  height: 500px;}#content {  background: #fff;  float: left;  width: 59%;  height: 500px;}#footer {  background: #0f0;  clear: both;  width: 100%;}--></style></head><body><div id="header">Header Section</div><div id="leftcol">Left Section</div><div id="rightcol">Right Section</div><div id="content">Content Section</div><div id="footer">Footer Section</div></body></html>

  5. Don't think so it's a good idea to use css when you're using tables.if you wanna use tables, you should put your css into xhtml, and if you wanna use css, then you have to build your xhtml with Divs.

  6. You asked for an exemple of little script so here it is, a script that'll tell you if an email if valid or not.

    <p><?if (isset($_POST['mail'])){	if (preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['mail']))	{		echo 'The email' . $_POST['mail'] . ' is<strong>valid</strong> !';	}	else	{		echo 'The email' . $_POST['mail'] . 'isnt valid, try again!';	}}?></p><form method="post"><p>	<label for="email">Your email ?</label> <input id="mail" name="mail" /><br />	<input type="submit" value="Try the email" /></p></form>

  7. I'm questioning myself about this since i've started to learn PHP, and I still really didnt find..In fact, the question's pretty simple. For exemple, you're doing a News system script, i dont understand how you can tell the script(the page where you write your news) to go at a specific place in the Index.I know that's a dumb question, but i didnt figure it out :)

  8. Not quite sure about it but i don't think so you can put a $_Post in your for each statment. You could do something like this

    $name = $_POST['vv'];

    and then you could do your foreach :

    foreach($name as $val)...

    I might be wrong, but you can try this out

  9. I use this code to show many time a page has been view and i know that fgets only take the first line of the file.

    <?php$monfichier = fopen('compteur.txt', 'r+');$pages_vues = fgets($monfichier)$pages_vues++;  fseek($monfichier, 0); fputs($monfichier, $pages_vues); fclose($monfichier);echo '<p>This page has been seen' . $pages_vues . ' time !</p>';?>

    My question is: is there a way to read more than the first line and not using While? (like an easy way to read lots of lines)Thanks.

  10. Let's say i have a forms where the guy put his name and whatever you want. Then when he hit 'submit' its going for exemple to welcome.php , my question is : How can i write $_POST['name'] in an echo? Thanks for your help.

×
×
  • Create New...