Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotes in String Problem (Basic)

Status
Not open for further replies.

clivehenderson

IS-IT--Management
Nov 2, 2002
66
0
0
GB
Hi Hope somrone can help with this
I'm trying to create a file from php.
It needs to contain this line
$dbname= "web39-databasename";

$conFile = "dbconn.php";
$fh = fopen($conFile, 'w') or die("can't open file");

$stringData = "\$dbname= ";
fwrite($fh, $stringData);
So I'd like $stringData to contain quotes name quotes
I've tried \"and "" without success
Any guidance at all might save me some hair
Many thanks
Clive
 
Just so I understand:
You want to wrap the web39-databasename string in double quotes correct?

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for the fast response
Yes
I'd like the write statement to put this format into the output file

$dbname= "web39-databasename";

So I've been trying to assign the above statement to a string without success.
Cheers
Clive



 
\" works. How were you trying to use it, exactly? (Code below does what you're trying to do.)

Code:
$conFile = "dbconn.php";
$fh = fopen($conFile, 'w') or die("can't open file");
$dbname = "web39-databasename";

fwrite($fh, "\$dbname=\"$dbname\";\n");

 
Something simple like:

Code:
$dbname=[green]'[/green]"web39-databasename"[green]'[/green];

Notice the single quotes around the entire thing.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top