franknu Posted May 8, 2007 Share Posted May 8, 2007 I have this code that when the user provide his email address he will participate in a raffle, my problem is that i want to select the id and the name but my selection is not workin here is my display 0 .Thank You. you are participarin to win a Brand new Laptop Here is your Lucky Number here is my code $sql="INSERT INTO `list` (`name`,`email`,`state`,`city`, `residential`,`commercial`) VALUES ('".$name."','".$email."','".$state."','".$city."','".$residential."','".$commercial."')"; $result = mysql_query($sql); echo mysql_error(); if($result) { $query = "SELECT * FROM `list` WHERE `email_id`= '$email_id' "; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_assoc($result); echo mysql_affected_rows()." .Thank You. $name<br> you are participarin to win a Brand new Laptop<br> Here is your Lucky Number <br>"; echo "$email_id "; } Quote Link to comment https://forums.phpfreaks.com/topic/50549-selecting/ Share on other sites More sharing options...
per1os Posted May 8, 2007 Share Posted May 8, 2007 The reason being is $email_id is not set anywhere. You may want to look into www.php.net/mysql_insert_id Quote Link to comment https://forums.phpfreaks.com/topic/50549-selecting/#findComment-248381 Share on other sites More sharing options...
franknu Posted May 8, 2007 Author Share Posted May 8, 2007 so there is not way of doing it the way i was doing it Quote Link to comment https://forums.phpfreaks.com/topic/50549-selecting/#findComment-248409 Share on other sites More sharing options...
per1os Posted May 8, 2007 Share Posted May 8, 2007 Not unless you set $email_id to have some type of a value, given the code you posted above $email_id is empty/null/nothing. You never instantiated/defined it. Quote Link to comment https://forums.phpfreaks.com/topic/50549-selecting/#findComment-248415 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.