fwrite($fh,
mysql_query("UPDATE config SET url='{$url}', shoutcast_url='{$shoutcast_url}', site_name='{$site_name}', site_subt开发者_开发问答itle='{$site_subtitle}', email_suffix='{$email_suffix}', twitter_username='{$twitter_username}', skype_name='{$skype_name}', phone_number='{$phone_number}'")
or die(mysql_error()); ?>);
Is there an easier way to fwrite this? (I know that won't work, but obviously it's very time consuming to format it correctly)
Thanks!
You can't use PHP
tag in PHP
code...
You must use it in ''
characters like a string.
I'm not sure what you want to do but if you just want to create some file with some content you may take a look at file_put_contents()
As Svisstack said, you should use '':
$code = '<?php
$fields = array("url", "shoutcast_url", "site_name", "site_subtitle", "email_suffix", "twitter_username", "skype_name", "phone_number");
foreach ($fields as $field) {
$$field = mysql_real_escape_string($_POST[$field]);
}
mysql_query("UPDATE config SET url=\'{$url}\', shoutcast_url=\'{$shoutcast_url}\', site_name=\'{$site_name}\', site_subtitle=\'{$site_subtitle}\', email_suffix=\'{$email_suffix}\', twitter_username=\'{$twitter_username}\', skype_name=\'{$skype_name}\', phone_number=\'{$phone_number}\'") or die(mysql_error());
?>';
fwrite($fh, $code);
精彩评论