SchweppesAle Posted May 5, 2009 Share Posted May 5, 2009 The following string will return everything up until the user's email address. Is there a reason why it cuts off short? $newuser_emailaddress = $_POST["newuser_emailaddress"]; $newuser_firstname = $_POST["newuser_firstname"]; $newuser_lastname = $_POST["newuser_lastname"]; $newuser_title = $_POST["newuser_title"]; $newuser_company = $_POST["newuser_company"]; $newuser_addressline1 = $_POST["newuser_addressline1"]; $newuser_addressline2 = $_POST["newuser_addressline2"]; $newuser_city = $_POST["newuser_city"]; $newuser_stateorprovince = $_POST["newuser_stateorprovince"]; $otherstateorprovince = $_POST["otherstateorprovince"]; $newuser_ziporpostalcode = $_POST["newuser_ziporpostalcode"]; $newuser_country = $_POST["newuser_country"]; $newuser_numberofemployees = $_POST["newuser_numberofemployees"]; $newuser_annualrevenue = $_POST["newuser_annualrevenue"]; $newuser_phone = $_POST["newuser_phone"]; $newuser_mobilephone = $_POST["newuser_mobilephone"]; $request = "<system>". "<action>addsubscriber</action>". "<authorization>". "<username>hidden</username>". "<password>hidden</password>". "</authorization>". "<parameterlist>". "<parameter id='List ID'><value>142</value></parameter>". "<parameter id='Auto-Activate'><value>true</value></parameter>". "<parameter id='newuser_emailaddress'><value>".$newuser_emailaddress."</value></parameter>". "<parameter id= 'newuser_firstname'><value>".$newuser_firstname."</value></parameter>". "<parameter id= 'newuser_lastname'><value>".$newuser_lastname."</value></parameter>". "<parameter id= 'newuser_title'><value>".$newuser_title."</value></parameter>". "<parameter id= 'newuser_company'><value>".$newuser_company."</value></parameter>". "<parameter id= 'newuser_addressline1'>".$newuser_addressline1."<value></value></parameter>". "<parameter id= 'newuser_addressline2'>".$newuser_addressline2."<value></value></parameter>". "<parameter id= 'newuser_city'><value>".$newuser_city."</value></parameter>". "<parameter id= 'newuser_stateorprovince'><value>".$newuser_stateorprovince."</value></parameter>". "<parameter id= 'otherstateorprovince'><value>".$otherstateorprovince."</value></parameter>". "<parameter id= 'newuser_ziporpostalcode'><value>".$newuser_ziporpostalcode."</value></parameter>". "<parameter id= 'newuser_country'><value>".$newuser_country."</value></parameter>". "<parameter id= 'newuser_numberofemployees'><value>".$newuser_numberofemployees."</value></parameter>". "<parameter id= 'newuser_annualrevenue'><value>".$newuser_annualrevenue."</value></parameter>". "<parameter id= 'newuser_phone'><value>".$newuser_phone."</value></parameter>". "<parameter id= 'newuser_mobilephone'><value>".$newuser_mobilephone."</value></parameter>". "</parameterlist>". "</system>"; Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/ Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Could you please run the following and post the result? var_dump($newuser_emailaddress); Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826696 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2009 Author Share Posted May 5, 2009 Could you please run the following and post the result? var_dump($newuser_emailaddress); sorry, it looks like I misunderstood the scope of variables in php. Another rooky mistake on my part. I had pulled the value of the variables via POST then attempted to input the value of a string which resided inside a method named sendEmail(); so basically some variables sendEmail() { $string = "blahblah".$variable."blahblah"; } [code] Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826700 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Nevermind. Sorry... Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826703 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2009 Author Share Posted May 5, 2009 wait, wouldn't they be considered local variables? var_dump($newuser_emailaddress); returns NULL ??? Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826704 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 It is. Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826707 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2009 Author Share Posted May 5, 2009 It is. strange that I would need to pass them via a parameter then. Here's a look at the entire thing, it's pretty straight forward though a good deal has been commented out. <?php $newuser_emailaddress = $_POST["newuser_emailaddress"]; $newuser_firstname = $_POST["newuser_firstname"]; $newuser_lastname = $_POST["newuser_lastname"]; $newuser_title = $_POST["newuser_title"]; $newuser_company = $_POST["newuser_company"]; $newuser_addressline1 = $_POST["newuser_addressline1"]; $newuser_addressline2 = $_POST["newuser_addressline2"]; $newuser_city = $_POST["newuser_city"]; $newuser_stateorprovince = $_POST["newuser_stateorprovince"]; $otherstateorprovince = $_POST["otherstateorprovince"]; $newuser_ziporpostalcode = $_POST["newuser_ziporpostalcode"]; $newuser_country = $_POST["newuser_country"]; $newuser_numberofemployees = $_POST["newuser_numberofemployees"]; $newuser_annualrevenue = $_POST["newuser_annualrevenue"]; $newuser_phone = $_POST["newuser_phone"]; $newuser_mobilephone = $_POST["newuser_mobilephone"]; echo $newuser_emailaddress; echo "<br/>"; //Testing to see if variables where passed correctly /* echo $newuser_emailaddress; echo $newuser_firstname; echo $newuser_lastname; echo $newuser_title; echo $newuser_company; echo $newuser_addressline1; echo $newuser_addressline2; echo $newuser_city; echo $newuser_stateorprovince; echo $otherstateorprovince; echo $newuser_ziporpostalcode; echo $newuser_country; echo $newuser_numberofemployees; echo $newuser_annualrevenue; echo $newuser_phone; echo $newuser_mobilephone; */ /** * StreamSend API Mailer Functions */ echo (sendEmail(/*$newuser_emailaddress,$newuser_firstname, $newuser_lastname, $newuser_title, $newuser_company, */)); function sendEmail(/*$newuser_emailaddress*/) { echo var_dump($newuser_emailaddress); // Fetch Your HTML Content /* $dbh = mysql_connect('XXX', 'XXX', 'XXX'); if ($dbh) { mysql_select_db('XXX'); } $get_mail_message = "SELECT * FROM tblEmailTemplate WHERE id='$email_id' LIMIT 1"; $get_mail_message_res = mysql_query($get_mail_message, $dbh) or die($get_mail_message . '-' . mysql_error()); $MessageInfo = mysql_fetch_object($get_mail_message_res); // If Sending a Test Message, Merge Any Subscriber Data $subject = mailMerge($MessageInfo->subject, $mail_info); $textbody = wordwrap(mailMerge($MessageInfo->textbody, $mail_info), 76, "\n"); $htmlbody = wordwrap(mailMerge($MessageInfo->htmlbody, $mail_info), 76, "\n"); */ // Build the XML for the Request $request = "<system>". "<action>addsubscriber</action>". "<authorization>". "<username>hidden</username>". "<password>hidden</password>". "</authorization>". "<parameterlist>". "<parameter id='List ID'><value>142</value></parameter>". "<parameter id='Auto-Activate'><value>true</value></parameter>". "<parameter id='newuser_emailaddress'><value>".$newuser_emailaddress."</value></parameter>". "<parameter id= 'newuser_firstname'><value>".$newuser_firstname."</value></parameter>". "<parameter id= 'newuser_lastname'><value>".$newuser_lastname."</value></parameter>". "<parameter id= 'newuser_title'><value>".$newuser_title."</value></parameter>". "<parameter id= 'newuser_company'><value>".$newuser_company."</value></parameter>". "<parameter id= 'newuser_addressline1'>".$newuser_addressline1."<value></value></parameter>". "<parameter id= 'newuser_addressline2'>".$newuser_addressline2."<value></value></parameter>". "<parameter id= 'newuser_city'><value>".$newuser_city."</value></parameter>". "<parameter id= 'newuser_stateorprovince'><value>".$newuser_stateorprovince."</value></parameter>". "<parameter id= 'otherstateorprovince'><value>".$otherstateorprovince."</value></parameter>". "<parameter id= 'newuser_ziporpostalcode'><value>".$newuser_ziporpostalcode."</value></parameter>". "<parameter id= 'newuser_country'><value>".$newuser_country."</value></parameter>". "<parameter id= 'newuser_numberofemployees'><value>".$newuser_numberofemployees."</value></parameter>". "<parameter id= 'newuser_annualrevenue'><value>".$newuser_annualrevenue."</value></parameter>". "<parameter id= 'newuser_phone'><value>".$newuser_phone."</value></parameter>". "<parameter id= 'newuser_mobilephone'><value>".$newuser_mobilephone."</value></parameter>". "</parameterlist>". "</system>"; echo $request; // Submit the Request to the API $response = SendRequest($request); return $response; } /* function mailMerge($MessageBody, $MergeInfo) { $MergedMessageBody = $MessageBody; if ($MergeInfo) foreach ($MergeInfo as $key => $value) $MergedMessageBody = preg_replace("/\{\{\{".$key."\}\}\}/", $value, $MergedMessageBody); return $MergedMessageBody; }*/ function SendRequest($request) { // Configuration $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; $url = "http://server1.streamsend.com/streamsend/api.php"; // Build Parameters $params['xmldata'] = $request; // Open Connection Handle $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$params); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); // Send Request $response = curl_exec ($ch); // Close Connection Handle curl_close ($ch); return $response; } ?> Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826710 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Functions in PHP do *not* read variables outside of its scope unless you call global on them. Although, I don't really see the advantage of global. I just pass the variables along. Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826716 Share on other sites More sharing options...
SchweppesAle Posted May 5, 2009 Author Share Posted May 5, 2009 Functions in PHP do *not* read variables outside of its scope unless you call global on them. Although, I don't really see the advantage of global. I just pass the variables along. alright, thanks for clearing that up then. I figured any variables declared within some class would be inherited by each of the functions within that class. My mistake. Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826721 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Oh, you should have told me that. In a class, you can reference the variables with the $this keyword. Example: class Blah { private $var = 1; public function getVar () { return $this->var; } } Notice how I called $this->var. People mess this up by variations such as: 1. $this->$var 2. this->$var 3. this->var Just know those are not correct syntactically and the script won't parse. Link to comment https://forums.phpfreaks.com/topic/156949-solved-php-strings/#findComment-826725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.