Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Special Interests > Web Design and Development
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 20, 2005, 11:49 AM   #1
Novark
macrumors newbie
 
Join Date: Dec 2005
Location: Canada
have a question about php

i don't have a mac but it seem like there was lots of help here.

this question is about php:
i want to know how to get rid of the \ befor every '.

now i will give you the situation:
i have made it so my firend can update his news on his webpage throught the browser . i made it so he inputs the date and i writes it to a file and then he inputs the new news and then it writes to another file and then he puts in his sig and i puts in into a nother file. then he sends it. the files then are taken into seperate arrays, then i used the implode functio to change them to strings then i brought the old news into an array, then i used the array_unshift to add all the new information into the old news, then i used the implode function on that, then i wrote over the file with the new string i hade which included the old news and the new news.

then the file is read into a seperate page
when it comes up on the page if i hade "wasn't" it would come up as "wasn\'t". what can i do to stop that from happening?
Novark is offline   Reply With Quote
Old Dec 20, 2005, 01:57 PM   #2
floyde
macrumors 6502a
 
floyde's Avatar
 
Join Date: Apr 2005
Location: Monterrey, México
Have you tried storing your ' as " ? Not sure that would work though, I've never used PHP, but I think it's something along those lines. Or use a replace function to get rid of them.
__________________
"He who will not reason is a bigot; he who cannot is a fool; and he who dares not is a slave."
floyde is offline   Reply With Quote
Old Dec 20, 2005, 02:16 PM   #3
Novark
Thread Starter
macrumors newbie
 
Join Date: Dec 2005
Location: Canada
this is the main code im using

PHP Code:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Put in the date:
<br>
<input type="text" name="date" size="20">
<br>
<input type="submit" name="submit1" value="Save Date">
</form>

<?php

//check for submit1
if(isset($_POST['submit1'])){
//set file to open'
$filedate 'gndate.txt';
//open the file
$fhdate fopen($filedate'w') or die('could not open the file');
//write to the file
fwrite($fhdate"<hr>".$_POST['date']."<br />\n") or die('could not write to the file');
//close the file
fclose($fhdate);
}

?>

<br>
<br>

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Put in the text you want entered
<br>
<textarea rows="20" name="textchange" cols="40">
</textarea>
<br>
<input type="submit" name="submit2" value="Add Entry">
</form>

<?php

//check for submit2
if(isset($_POST['submit2'])){
//set file to open
$filetext 'gntext.txt';
//open the file
$fhtext fopen($filetext'a') or die('could not open the file');
//write to the file
fwrite($fhtext"<br /><img src=\"Pictures/Goldchip.gif\" width=\"10\" height=\"10\">\n".$_POST['textchange']."<br />\n");
//close the file
fclose($fhtext);
}

?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="submit4" value="Erase text file">
</form>

<?php


//check for submit4
if(isset($_POST['submit4'])){
//set file to open
$fileerase 'gntext.txt';
//open the file
$fherase fopen($fileerase'w') or die('could not open the file');
//erase the file
fwrite($fherase) or die('could not write the file');
//close the file
fclose($fherase);
}

?>


<br>
<br>


<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Put in you sig
<br>
<input type="text" name="sig" size="20">
<br>
<input type="submit" name="submit3" value="Save Sig">
</form>

<?php


//check for submit3
if(isset($_POST['submit3'])){
//set the file to open
$filesig 'gnsig.txt';
//open the file
$fhsig fopen($filesig'w') or die('could not open the file');
//write the file
fwrite($fhsig"<br /><div align=\"right\">".$_POST['sig']."</div>\n") or die('could not write the file');
//close the file
fclose($fhsig);
}

?>


<br>
<br>
<br>


<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="submit5" value="SEND">
</form>

<?php


//check for SEND
if(isset($_POST['submit5'])){
//set files
$add1 'gndate.txt';
$add2 'gntext.txt';
$add3 'gnsig.txt';
$addto 'gnews.txt';
//open the files to add
$dataadd1 file($add1) or die('could not oopen the file');
$dataadd2 file($add2) or die('could not oopen the file');
$dataadd3 file($add3) or die('could not oopen the file');
$dataaddto file($addto) or die('could not oopen the file');
//implode the arrays to be added
$newadd1 implode(' '$dataadd1);
$newadd2 implode(' '$dataadd2);
$newadd3 implode(' '$dataadd3);
//add them to the news
array_unshift($dataaddto$newadd3);
array_unshift($dataaddto$newadd2);
array_unshift($dataaddto$newadd1);
//implode the news array
$newaddto implode(' '$dataaddto);
//set the file to add the new news to
$finalnews 'gnews.txt';
//open the file
$fhfinalnews fopen($finalnews'w') or die('could not open the file');
//write the final news
fwrite($fhfinalnews$newaddto) or die('could not write to the file');
//close the file
fclose ($fhfinalnews);


//open files
$senderase1 'gndate.txt';
$senderase2 'gntext.txt';
$senderase3 'gnsig.txt';
//open the files
$fhsenderase1 fopen($senderase1'w') or die('could not open the file');
$fhsenderase2 fopen($senderase2'w') or die('could not open the file');
$fhsenderase3 fopen($senderase3'w') or die('could not open the file');
//erase the files
fwrite($fhsenderase1) or die('could not write the file');
fwrite($fhsenderase2) or die('could not write the file');
fwrite($fhsenderase3) or die('could not write the file');
//close the files
fclose($fhsenderase1);
fclose($fhsenderase2);
fclose($fhsenderase3);
}


?>


<br>
<b><u>PRIVEW</u></b>
<br>
This is what you have so far:


<?php


//set the file to open
$readdate 'gndate.txt';
//open the file
$readdatadate file($readdate) or die('<br />nothing in the file\'s');
//read the fileinto the browser
foreach ($readdatadate as $readdateline){
echo 
$readdateline;
}


//set the file to open
$readtext 'gntext.txt';
//open the file
$readdatatext file($readtext) or die('<br />nothing in the file\'s');
//read the file into the bowser
foreach ($readdatatext as $readtextline){
echo 
$readtextline;
}


//set the file to open
$readsig 'gnsig.txt';
//open the file
$readdatasig file($readsig) or die('<br />nothing in the file\'s');
//read the file into the browser
foreach ($readdatasig as $readsigline){
echo 
$readsigline;
}


?>
as you can see i have no control when and where the " ' " comes in, it is all up to the user, when he types it in is whne it is put in there so i can't isolate them all and change it into &quote.

this is the websight where i have it set up: http://members.lycos.co.uk/phpsight1101/

Last edited by Novark : Dec 20, 2005 at 02:28 PM.
Novark is offline   Reply With Quote
Old Dec 20, 2005, 03:47 PM   #4
superbovine
macrumors 68030
 
superbovine's Avatar
 
Join Date: Nov 2003
stripslashes is your friend. You should also read about magic_quote on php.net it goes quote well with stripslashes and doing mysql work.

http://us3.php.net/manual/en/function.stripslashes.php

PHP Code:
<?php
$str 
"Is your name O\'reilly?";

// Outputs: Is your name O'reilly?
echo stripslashes($str);
?>
__________________
Cowzilla The Feed Monster
superbovine is offline   Reply With Quote
Old Dec 20, 2005, 10:15 PM   #5
Novark
Thread Starter
macrumors newbie
 
Join Date: Dec 2005
Location: Canada
thanx

thank you soo much it works and it is my new friend
Novark is offline   Reply With Quote

Reply

Mac Forums > Special Interests > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:16 AM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 2002-2009, MacRumors.com, LLC