darkfreaks Posted October 16, 2007 Share Posted October 16, 2007 anyone got any ideas why ? ??? Register.php <?php include("connect.php"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!preg_match('/([a-zA-z0-9\.\-]+)@([a-zA-Z0-9\.\-]+)\.([a-zA-Z]{2,3})/',$_POST['nmail'],$m)){ die('Invalid Email Address.'); $name = htmlentities($_POST['name']);} if (empty($name)){ die("Please fill in both your name and email address to subscribe to our newsletter."); $nmail = $m[0]; $link = "SELECT * FROM users WHERE nmail='$nmail'"; $res = mysql_query($link) or die(mysql_error());} if (mysql_num_rows($res) > 0){ die("Sorry, This email address appears to already be registered to receive our newsletter<br />If you feel this is a mistake,<br />Please contact us to look into it for you."); $link = "INSERT INTO users VALUES ('$name','$nmail',NOW(),'subscribed','0','')"; $res= mysql_query($link) or die(mysql_error());} if ($res){ die("Your Email address has been Succesfully Registerted to receive our newsletter."); } else { echo '<html><head><title>Sign Up</title></head> <body><center><br /><br /> <form action="" method="POST"> Name <input type="text" name="name"><br /> Email <input type="text" name="nmail"><br /><br /> <input type="submit" value="Sign up"> </form> </body> </html>'; } ?> Unsubscibe.php <?php include("connect.php"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $nmail = preg_replace("#'//\<>#","",$_POST['nmail']); if (empty($nmail)){ die("Please enter an email address.");} $link = "UPDATE users SET status='un',unsubscribed='1' WHERE nmail='$nmail'"; $res = mysql_query($link) or die(mysql_error()); if ($res){ die("You have been Succesfully Unsubscrbied from our newsletter<br /><br />If you have any suggestions or would like to comment on why you no longer wish to receive our newsletter<br /><br />Please feel free to contact us.");} } else { echo ' <html><head><title>Unsubscribe</title></head> <body> <form action="" method="POST"> Email <input type="text" name="nmail"><br /><br /> <input type="submit" value="Unsubscribe"> </form> </body> </html>'; } ?> index.php <?php if ($index_refer <> 1) { exit(include("includes/readcookie.inc.php")); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Newsletter</title> </head> <body> <font face=arial size=3 color=blue> Sign up to our newsletter / mailing list <a href="index.php?dir=addons/newsletter&page=register">Here</a><br /><br /> Unsubscribe from our newsletter <a href="index.php?dir=addons/newsletter&page=unsubscribe">Here</a><br /><br /> </body> </html> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 in the error message it says something to do with a function on line 25 of readcookie.inc.php ??? Quote Link to comment Share on other sites More sharing options...
trq Posted October 16, 2007 Share Posted October 16, 2007 it says something to do with a function on line 25 Can you be a little more vague please? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 here is the function on line 25 which returns Fatal error: cannot declare previous stated function on line 25 so i looked up the function which is <?php function assign_rand_value($num) { // for random session id >> accepts 1 - 36 switch($num) { case "1": $rand_value = "a"; break; case "2": $rand_value = "b"; break; case "3": $rand_value = "c"; break; case "4": $rand_value = "d"; break; case "5": $rand_value = "e"; break; case "6": $rand_value = "f"; break; case "7": $rand_value = "g"; break; case "8": $rand_value = "h"; break; case "9": $rand_value = "i"; break; case "10": $rand_value = "j"; break; case "11": $rand_value = "k"; break; case "12": $rand_value = "l"; break; case "13": $rand_value = "m"; break; case "14": $rand_value = "n"; break; case "15": $rand_value = "o"; break; case "16": $rand_value = "p"; break; case "17": $rand_value = "q"; break; case "18": $rand_value = "r"; break; case "19": $rand_value = "s"; break; case "20": $rand_value = "t"; break; case "21": $rand_value = "u"; break; case "22": $rand_value = "v"; break; case "23": $rand_value = "w"; break; case "24": $rand_value = "x"; break; case "25": $rand_value = "y"; break; case "26": $rand_value = "z"; break; case "27": $rand_value = "1"; // no zeros, because if it starts with a zero, it might get cut off break; case "28": $rand_value = "1"; break; case "29": $rand_value = "2"; break; case "30": $rand_value = "3"; break; case "31": $rand_value = "4"; break; case "32": $rand_value = "5"; break; case "33": $rand_value = "6"; break; case "34": $rand_value = "7"; break; case "35": $rand_value = "8"; break; case "36": $rand_value = "9"; break; } return $rand_value; }?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 see this link http://www.php.net/manual/en/function.function-exists.php and dude you can have that code in i guess less that 6 lines Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 can ya redo it for me? if i could do it in 6 lines instead of 30 that would be awesome. Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 heres your function with morethan 30 lines lollol function assign_rand_value($num){ $numbers = range(1,35); $letters = range('a','z'); array_push($letters,1,1,2,3,4,5,7,8,9); $values = array_combine($numbers ,$letters); return $values[$num]; } Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 yours is 40 lines lol mine is 7 lines and if you want to have shorter you can have that in 4 lines Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 lol it works thanks and alot shorter now i need to figure out how to include function_exists so it will ignore it and wont give me the error ??? Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 if (!function_exists('assign_rand_value')) { function assign_rand_value($num){ $numbers = range(1,35); $letters = range('a','z'); array_push($letters,1,1,2,3,4,5,7,8,9); $values = array_combine($numbers ,$letters); return $values[$num]; } } Quote Link to comment Share on other sites More sharing options...
448191 Posted October 16, 2007 Share Posted October 16, 2007 include_once Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 teng your solution does not work it still returns as cannot declare function ??? Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 include_once include_once("includes/readcookie.inc.php")); i dont know if his will help http://www.php.net/manual/en/function.unregister-tick-function.php Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 i tried putting <?php if ($index_refer <> 1) { exit(include("includes/readcookie.inc.php")); }?> still no luck Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 try --- unregister_tick_function('assign_rand_value'); function assign_rand_value($num){ $numbers = range(1,35); $letters = range('a','z'); array_push($letters,1,1,2,3,4,5,7,8,9); $values = array_combine($numbers ,$letters); return $values[$num]; } or remove this include_once("includes/readcookie.inc.php") <?php if ($index_refer <> 1) { exit(); }?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 tried both none of those work i thought it was the include thing too teng but its not :-\ Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 try this to check whether that function is already defined $arr = get_defined_functions(); print_r($arr); or check maybe your function is inside the loop or maybe your include is inside the loop Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 Fatal error: Call to undefined function: array_combine() in /home/lilysgra/public_html/lilysgraveyard/includes/readcookie.inc.php on line 29 Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 nah what version of php is that? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 i got version 4.4 would array_merge work? Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 im not the right person to answer this i hate lower version Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 i used array_merge it works but now i get Unknown column '3032b3528303032' in 'where clause' Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 maybe that means your data dont maths your fields datatypes when your field is int and you enter string that will happen Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 16, 2007 Author Share Posted October 16, 2007 how would i offset this? should i just put the old func back? :-\ Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 16, 2007 Share Posted October 16, 2007 maybe if int is the field remove the '' around it or vise versa Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.