B8777 Posted August 1, 2011 Share Posted August 1, 2011 Hi, I have the following code: <?php include("../include/include.php"); ?> <table border="1"> <tr> <th>News letter</th> </tr> <tr> <td><a href="newsletter.php?action=send">Send letter</a></td> </tr> </table><br><br><br> <?php if(isset($_GET['action']) && $_GET['action'] == "send"){ if(isset($_POST['message']) && isset($_POST['title'])){ $message = explode("[bLOCK]",$_POST['message']); $newmessage = ""; for($i = 0; $i < count($message); $i++){ $message[$i] = stripslashes(ereg_replace("\n","<br>",$message[$i])); $newmessage .= parse("rownewsletter",$message[$i]); } $message = $newmessage; $query = "SELECT * FROM ".$_table['users']." WHERE 1 ".($_POST['test'] == 'test' ? 'AND (id=\'2\')' : '')." ORDER BY id ASC"; // OR id=\'6\' OR id=\'486358\' OR id=\'486359\' $query = $_DBC->sql_query($query,0); $i = 0; $a = 0; $this = 0; while($row = $_DBC->sql_fetch_assoc($query)){ $ad = ""; /* $nthis = $this; for($a = $a; $a < $nthis + 2; $a++){ $ad .= $ads[$a]."<hr width=\"50%\">"; $this++; } */ for($a = 0; $a < count($ads); $a++){ $ad .= $ads[$a]."<hr width=\"50%\">"; } $content = $message . parse("rownewsletterads",$ad); if($a == count($ads)){ $a = 0; $this = 2; } $content = ereg_replace("!mail!",$row['email'],$content); $content = ereg_replace("!id!",$row['id'],$content); $content = ereg_replace("!date!",date('d-m-Y',$row['time']),$content); email($row['email'],$row['email'],$_POST['title'],$content,'','','','','newsletter'); $i++; } if($_POST['test'] != "test"){ $query = $_DBC->sql_query("INSERT INTO ".$_table['newsletter']." (subject,message,time) VALUES ('".$_POST['title']."','".addslashes($message)."','".dtime()."')",0); } echo("The newsletter is send to ".$i." users."); }else{ ?> <table> <form method="post"> <tr> <td>Subject:</td> <td><input type="text" name="title" value="<?php echo $_POST['title']; ?>" size="18"></td> </tr> <tr> <td colspan="2">Message:</td> </tr> <tr> <td colspan="2"><textarea name="message" rows="10" cols="40"><?php echo $_POST['message']; ?></textarea><br>You can use the follow code's:<br>* !mail! replace to the user's email<br>* !id! replace to the user's ID<br>* !date! replace to the signup date</td> </tr> <tr> <td colspan="2"><input type="checkbox" name="test" value="test" checked> Tes only account #ID 1</td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="Send letter"></td> </tr> </form> </table> <?php } } ?> <?php $_DBC->sql_close(); ?> But then I get the following error: Fatal error: Cannot re-assign $this But I don't know what I am doing wrong, it worked a while ago! Can somebody help me? Thanks Link to comment https://forums.phpfreaks.com/topic/243524-cannot-re-assign-this-error/ Share on other sites More sharing options...
IrOnMaSk Posted August 1, 2011 Share Posted August 1, 2011 if i count the {} right, you're assigning $this with two values... put the code in notepad and attach it here, i can open in my editor now i can't... Link to comment https://forums.phpfreaks.com/topic/243524-cannot-re-assign-this-error/#findComment-1250467 Share on other sites More sharing options...
requinix Posted August 1, 2011 Share Posted August 1, 2011 You cannot use "this" as a variable name. Choose something else. Link to comment https://forums.phpfreaks.com/topic/243524-cannot-re-assign-this-error/#findComment-1250470 Share on other sites More sharing options...
IrOnMaSk Posted August 1, 2011 Share Posted August 1, 2011 aaahhh, "this" is reserved keyword or variale or watever,,,, use something else Link to comment https://forums.phpfreaks.com/topic/243524-cannot-re-assign-this-error/#findComment-1250478 Share on other sites More sharing options...
B8777 Posted August 1, 2011 Author Share Posted August 1, 2011 Thanks guys! It works Link to comment https://forums.phpfreaks.com/topic/243524-cannot-re-assign-this-error/#findComment-1250483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.