fert Posted December 9, 2006 Share Posted December 9, 2006 i have this code:[code]function curl_mail($to,$subject,$msg,$headers) { $values=array("to"=>$to,"subject"=>$subject,"msg"=>$msg,"headers"=>$headers); $cur=curl_init("http://www.mysite.net/mail_to.php"); curl_setopt($cur,CURLOPT_POST,true); curl_setopt($cur,CURLOPT_POSTFIELDS,$values); curl_exec($cur); curl_close($cur); }$letters=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"); $num=rand(3,20); for($count=0;$count<$num;$count++) { $sesid[$count]=$letters[rand(0,35)]; $ses.=$sesid[$count]; } $result=@mysql_query("SELECT * FROM `users` WHERE `sesid`='$ses'",$cn) or die(mysql_error()); while(mysql_num_rows($result)!=0) { $num=rand(3,20); for($count=0;$count<$num;$count++) { $sesid[$count]=$letters[rand(0,35)]; $ses.=$sesid[$count]; } $result=@mysql_query("SELECT * FROM `users` WHERE `sesid`='$ses'",$cn) or die(mysql_error()); } $pword=md5($_POST['password']); $uname=mysql_real_escape_string($_POST['username']); $e_mail=mysql_real_escape_string($_POST['email']); @mysql_query("INSERT INTO `users` (username,password,email,sesid,active) VALUES('$uname','$pword','$e_mail','$ses','0')",$cn) or die(mysql_error()); curl_mail($_POST['username'],"Registration","Thank you for registering when logging for the first time use: {$ses} as your password","From: Person");[/code]when i run it i get a server error from the server that the curl_mail() function uses. any ideas why? Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/ Share on other sites More sharing options...
ToonMariner Posted December 9, 2006 Share Posted December 9, 2006 try initializing the $ses var befoer you use it.$ses = NULL;$num=rand(3,20); for($count=0;$count<$num;$count++) { $sesid[$count]=$letters[rand(0,35)]; $ses.=$sesid[$count]; } Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137856 Share on other sites More sharing options...
fert Posted December 9, 2006 Author Share Posted December 9, 2006 nope that didn't work. Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137860 Share on other sites More sharing options...
ToonMariner Posted December 9, 2006 Share Posted December 9, 2006 ooops didn't read all your post.if all that is supposed to be one function you have terminated the curl_mail function after 6 lines of code.If not that then you must trace back each assignment of each var that makes up $ses. Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137867 Share on other sites More sharing options...
fert Posted December 9, 2006 Author Share Posted December 9, 2006 with this code: [code]$ses=NULL; $letters=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"); $num=rand(3,20); for($count=0;$count<$num;$count++) { $sesid[$count]=$letters[rand(0,35)]; $ses.=$sesid[$count]; } echo $ses; $result=@mysql_query("SELECT * FROM `users` WHERE `sesid`='$ses'",$cn) or die(mysql_error()); while(mysql_num_rows($result)!=0) { $num=rand(3,20); for($count=0;$count<$num;$count++) { $sesid[$count]=$letters[rand(0,35)]; $ses.=$sesid[$count]; } $result=@mysql_query("SELECT * FROM `users` WHERE `sesid`='$ses'",$cn) or die(mysql_error()); } $pword=md5($_POST['password']); $uname=mysql_real_escape_string($_POST['username']); $e_mail=mysql_real_escape_string($_POST['email']); $msg="Thank you for registering when logging for the first time use: {$ses} as your password"; echo $msg; @mysql_query("INSERT INTO `users` (username,password,email,sesid,active) VALUES('$uname','$pword','$e_mail','$ses','0')",$cn) or die(mysql_error()); //curl_mail($_POST['username'],"Registration",$msg,"From: Person");[/code]i get: 2jfn5qzljgsly3apogThank you for registering when logging for the first time use: 2jfn5qzljgsly3apog as your password Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137870 Share on other sites More sharing options...
fert Posted December 9, 2006 Author Share Posted December 9, 2006 *bump Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137889 Share on other sites More sharing options...
trq Posted December 9, 2006 Share Posted December 9, 2006 Please read the link in my signiture. Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137900 Share on other sites More sharing options...
fert Posted December 9, 2006 Author Share Posted December 9, 2006 The code that i posted is part of a script for users to register on my website I'm user the curl_mail() function because my server doesn't have a mail server and the server that the curl_mail() function accesses has one. If i take out the {$ses} out of the variables passed to the curl_mail() function the function works, otherwise i get a server error from the server that the curl_mail function uses. And when i log in my apache error log it says something along the lines of "PHP error: Undefined variable 'ses' on line 40 in htdocs/msgs/register.php. Refer htdocs/msgs/register.php" Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137913 Share on other sites More sharing options...
bljepp69 Posted December 9, 2006 Share Posted December 9, 2006 In the last code you posted, you had called curl_mail() like this:[quote]curl_mail($_POST['username'],"Registration",$msg,"From: Private msgs Admin <[email protected]>");[/quote]Did that work? It should work better than what you had before because you've now defined a variable, $msg, that would contain the value of $ses. It looks like the output echoed is what you are looking for.I suspect the reason it didn't work the way you originally called curl_mail():[quote]curl_mail($_POST['username'],"Registration","Thank you for registering when logging for the first time use: {$ses} as your password","From: Person");[/quote]is because you literally passed "...use: {$ses} as..." and not the value of $ses. Then, when the function tried to process the comment, it tried to parse $ses and that's where you got the error. Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137920 Share on other sites More sharing options...
fert Posted December 9, 2006 Author Share Posted December 9, 2006 the last code i posted didn't work, it's still giving me the same error Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137921 Share on other sites More sharing options...
fert Posted December 9, 2006 Author Share Posted December 9, 2006 I found out what i did wrongi used $_POST['username'] instead of $_POST['email'] in the following line:[code]curl_mail($_POST['username'],"Registration",$msg,"From: Private msgs Admin <[email protected]>");[/code] Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137928 Share on other sites More sharing options...
trq Posted December 9, 2006 Share Posted December 9, 2006 [quote]I found out what i did wrong[/quote]Good. Next time please take the time to edit your thread and mark it resolved. Link to comment https://forums.phpfreaks.com/topic/29994-resolved-undefined-variable-ses/#findComment-137929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.