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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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