Jump to content

[SOLVED] fwrite trouble


matthewst

Recommended Posts

I have this code:

<select name="header" size="1">
        <option value="">-- Select a header image --</option>
        <option value="<?php echo "<img src='../../styles/BBQ1.jpg'>" ?>">BBQ 1</option>
        <option value="<?php echo "<img src='../../styles/BBQ2.jpg'>" ?>">BBQ 2</option>
        <option value="<?php echo "<img src='../../styles/BBQ3.jpg'>" ?>">BBQ 3</option>
        <option value="<?php echo "<img src='../../styles/Garden1.jpg'>" ?>">Garden 1</option>
        <option value="<?php echo "<img src='../../styles/Gray1.jpg'>" ?>">Gray 1</option>
        <option value="<?php echo "<img src='../../styles/Wine1.jpg'>" ?>">Wine1</option>
        </select>

 

pointing to this code on another page:

$stringData = "<table width='60%' height='95%' border='0'><tr><td colspan='2' align='center' height='75px'>$header";
fwrite($fh, $stringData);

 

it keeps adding backslashes to the string:

<table width='60%' height='95%' border='0'><tr><td colspan='2' align='center' height='75px'><img src=\'../../styles/BBQ3.jpg\' />

right after src= and right after bbq3.jpg

 

Any one know where they're coming from?

Link to comment
https://forums.phpfreaks.com/topic/69187-solved-fwrite-trouble/
Share on other sites

I tried:

stripslashes ($header);
$stringData = "<table width='60%' height='95%' border='0'><tr><td colspan='2' align='center' height='75px'>$header";
fwrite($fh, $stringData);

and this:

$stringData = "<table width='60%' height='95%' border='0'><tr><td colspan='2' align='center' height='75px'>$header";
stripslashes ($stringData);
fwrite($fh, $stringData);

but it doesn't do anything.

Link to comment
https://forums.phpfreaks.com/topic/69187-solved-fwrite-trouble/#findComment-347769
Share on other sites

If you don't want to use magic quotes at all (which I recommend not using it) You can turn magic quotes gpc and runtime off using http://php.net/ini_set or if you have access to your php.ini file, in there.

 

I don't quite see where you're even writing that variable, so it's hard to see where to use it. Your code doesn't make sense to me.

I guess use it on your fwrite part?

 

edit: you have to assign it to a new string. $header = stripslashes($header). See in the manual that it returns a string?

Link to comment
https://forums.phpfreaks.com/topic/69187-solved-fwrite-trouble/#findComment-347770
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.