Jump to content

File Write " and ' closing early issu


kiksy

Recommended Posts

Hi there,

 

Ive searched around , but due to the grammatical style of my problem its been hard to find an answer on Google or here.

 

I am inserting some PHP/MySQL commands into a new .php file using 'fwrite' :

 

$stringData = '";
$dbresult = mysql_query("SELECT * FROM PhotoUsers WHERE id = "';
fwrite($fh, $stringData);
$stringData = '$idselect';
fwrite($fh, $stringData);
$stringData = '");

 

When run the resulting .php file contains :

$dbresult = mysql_query("SELECT * FROM PhotoUsers WHERE id = "$idselect"");

 

Where as it needs to be :

 

$dbresult = mysql_query("SELECT * FROM PhotoUsers WHERE id = '$idselect'");

 

with '' instead of "" around $idselect.

 

The issue is that when I put ' around $stringData = '$idselect'; in the first page it closes it.

 

I hope Ive explained my issue clearly, thanks in advance for any help, Im sure its a simple fix!

 

 

 

 

Link to comment
Share on other sites

well Kiksy doesn't use slash here. Or I misunderstood the suggestion.

I believe he was having troubles trying to achieve the second output; with single quotes closing the string.. Basically using a single quote within single-quoted string.

 

If I've confused you, this should work for you kiksy:

 

$stringData = '$dbresult = mysql_query("SELECT * FROM PhotoUsers WHERE id = \'$idselect\'");';
fwrite($fh, $stringData);

Link to comment
Share on other sites

Thanks,

 

I was jut away entering what you suggested when you put that second post down. It works perfectly with :

 

$stringData = '";
$dbresult = mysql_query("SELECT * FROM PhotoUsers WHERE id = ';
fwrite($fh, $stringData);
$stringData = '\'$idselect\'';
fwrite($fh, $stringData);

 

Thanks for the quick response!  8)

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.