xwishmasterx Posted April 8, 2011 Share Posted April 8, 2011 I have an error somewhere in the form as it does not output what I want it too. I know the form itself is working as I have added an echo to see if the form inputs are processed. the code: <?php $amount = $_POST['amount']; $member = $_POST['member']; $sql = ("SELECT name FROM vtp_members WHERE name=".$member." "); $result = mysql_query($sql); $numrows = mysql_num_rows($result); if($numrows = '1') { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "You sent ". $amount . " to " . $member . ".<br />"; } } echo " ".$amount." and ".$member." "; ?> It outputs the last echo correct. is there anyone who can see what I'm doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/ Share on other sites More sharing options...
spiderwell Posted April 8, 2011 Share Posted April 8, 2011 if($numrows = '1') look closer Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199032 Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 Try: $sql = "SELECT name FROM vtp_members WHERE name='$member'"; And change: if($numrows = '1') To: if($numrows == '1') See if that clears things up. Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199033 Share on other sites More sharing options...
spiderwell Posted April 8, 2011 Share Posted April 8, 2011 damn i keep missing those single quote errors lol Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199034 Share on other sites More sharing options...
xwishmasterx Posted April 8, 2011 Author Share Posted April 8, 2011 thank you both. Sometimes you just need someone else to take a look too find the stupid mistakes Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199037 Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 While you're at it, there's no need to concatenate the variables into the strings all the time like that. The output from the following is the same as what will be generated by your echoes. echo "You sent $amount to $member<br />"; } } echo " $amount and $member"; Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199038 Share on other sites More sharing options...
dcro2 Posted April 8, 2011 Share Posted April 8, 2011 Moral of the story: always check if your queries succeeded. Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199039 Share on other sites More sharing options...
spiderwell Posted April 8, 2011 Share Posted April 8, 2011 While you're at it, there's no need to concatenate the variables into the strings all the time like that. The output from the following is the same as what will be generated by your echoes. echo "You sent $amount to $member<br />"; } } echo " $amount and $member"; is there a performance difference with doing it this way? i always use the . concatenate method , just because i find it easier to read in notepad++, lol Quote Link to comment https://forums.phpfreaks.com/topic/233149-error-on-simple-form/#findComment-1199043 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.