Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:06:56+00:00 2026-06-02T16:06:56+00:00

basically I am try to get the php file to create another php file

  • 0

basically I am try to get the php file to create another php file which has XHTML, PHP and MYSQL within it. I am trying to include a MYSQL query but the problem is that the apostrophe (‘) that I use to start the fwrite string get confused when it reaches a MYSQL query because it too also has an apostrophe but I just want that string to continue not end. What should I do for this to work? Thanks in advance for any help.

The code (just the relevant bit):

$filename = "websites/".$firstpage.".php";
$filehandle = fopen($filename, 'w') or die("error opening file");
$datawrite = '
$query = "SELECT websitetitle FROM $weblist WHERE webID='$webID'";
$result =  mysql_query ($query);
$row = mysql_fetch_array( $result );

echo $row['webID'];

';
fwrite($filehandle, $datawrite);

fclose($filehandle);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:06:56+00:00Added an answer on June 2, 2026 at 4:06 pm

    You should escape the ‘ in the query with \’ This will not exec and end the string

    $filename = "websites/".$firstpage.".php";
    $filehandle = fopen($filename, 'w') or die("error opening file");
    $datawrite = '
        $query = "SELECT websitetitle FROM $weblist WHERE webID=\'$webID\'";
        $result =  mysql_query ($query);
        $row = mysql_fetch_array( $result );
    
        echo $row[\'webID\'];
    
    ';
    fwrite($filehandle, $datawrite);
    
    fclose($filehandle);
    

    Check this out for reference
    http://php.net/manual/en/language.types.string.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using mysql (and php) I try to hide out of a select menu category's
I am trying to get apache/php to recognize the path to my git. I
I am using PHP to generate a report, which is basically a one line
Shortened Aim: To pass a variable via $.POST to a PHP file (get.php), and
Basically I'm trying to get a bit of regex to do the following... I
I was trying to update from php 5.2 to php 5.3. Basically what I
I've been trying to get this working, and not having 100% success, basically trying
I get the following error message when i try to run some php code
I' still newby to this so I'll try to explain what I'm doing. Basically
What I would like to do is retrieve the contents of a PHP file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.