XpertWorlock Posted September 8, 2008 Share Posted September 8, 2008 $Content = (" <?php include 'siteLayout.php'; $con = mysql_connect('localhost:2222',"******","********"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*********", $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_array($result)) { echo $row['userName']; } mysql_query(\"INSERT INTO users (userName, userPassword, userEmail) VALUES ('$signUpName', '$signUpPassword', '$signUpEmail')\"); echo \"<table border='1'><tr><td> Your account has been activated.<br><br>Please log in. </td></tr></table>\"; ?> \r\n"); $handle = fopen($fileName, 'x+'); fwrite($handle, $Content); fclose($handle); $con = mysql_connect('localhost:2222',"*******","*********"); This is the part of code where the error comes up. "Unexpected T_STRING." $Content is the content of the php file being written. Help is appreciated, I've tried everything I could think of. Link to comment https://forums.phpfreaks.com/topic/123190-solved-script-wont-work-creating-a-php-file/ Share on other sites More sharing options...
DarkWater Posted September 8, 2008 Share Posted September 8, 2008 You can't use double quotes inside of double quotes. Link to comment https://forums.phpfreaks.com/topic/123190-solved-script-wont-work-creating-a-php-file/#findComment-636226 Share on other sites More sharing options...
fenway Posted September 8, 2008 Share Posted September 8, 2008 You can't use double quotes inside of double quotes. Well, you can, but not without escaping them... so you shouldn't. Link to comment https://forums.phpfreaks.com/topic/123190-solved-script-wont-work-creating-a-php-file/#findComment-636250 Share on other sites More sharing options...
XpertWorlock Posted September 8, 2008 Author Share Posted September 8, 2008 $Content = (" <?php include 'siteLayout.php'; $con = mysql_connect('localhost:2222','*****','********'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('********', $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_array($result)) { echo $row['userName']; } mysql_query("INSERT INTO users (userName, userPassword, userEmail) VALUES ('$signUpName', '$signUpPassword', '$signUpEmail')\"); echo \"<table border='1'><tr><td> Your account has been activated.<br><br>Please log in. </td></tr></table>\"; ?> \r\n"); $handle = fopen($fileName, 'x+'); fwrite($handle, $Content); fclose($handle); Sorry I was copying an example of the code, I actually just use a function, so I now copied the official function. Again it's $result = mysql_query("SELECT * FROM users"); that gives the T_STRING error thanks for the replies so far Link to comment https://forums.phpfreaks.com/topic/123190-solved-script-wont-work-creating-a-php-file/#findComment-636257 Share on other sites More sharing options...
XpertWorlock Posted September 8, 2008 Author Share Posted September 8, 2008 Nevermind, I found out double quotes, even when used with care, can end up biting you in the ass. In this case, it was functions within other things, the functions contained double quotes and messed everything up. Link to comment https://forums.phpfreaks.com/topic/123190-solved-script-wont-work-creating-a-php-file/#findComment-636259 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.