Jump to content

unistake

Members
  • Posts

    445
  • Joined

  • Last visited

Everything posted by unistake

  1. That is what i have been doing.... this is everything. <?php include("db.php"); $user = $_COOKIE["user"]; $cxn = mysqli_connect($host,$username,$password,$database) or die ("couldn't connect to server"); $query = "SELECT code FROM Member WHERE user='$user'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); $nrows = mysqli_num_rows($result); while($row = mysqli_fetch_assoc($result)) { if ($row['code'] !=0) { $query = "SELECT * FROM Member WHERE friend='" . $row['code'] . "'"; $rs = mysqli_query($cxn,$query) or die ("Couldn't execute query."); $nrs = mysqli_num_rows($rs); $referred = $nrs-1; echo $referred; } else echo "0"; } ?> Database: Member userID user friend code 28 123name testcode 31 user123 testcode Everything i have given you is "as is".
  2. Still echoing "0"! Is there any other way that I can do this sort of referral thing? All I want to do is to allow my users to make a unique referral code. So that their friends can type it in when registering. Then the user can track his/her friends. Any suggestions would be appreciated.
  3. The same thing happens unfortunately Ken. Thanks for showing me that problem though
  4. that echos the correct value in the db field. no problem there! I dont understand that $code does have a value with it, but for some reason skips to the ELSE statement.
  5. ok tried that but the echos are exactly like the line below SELECT code FROM Member WHERE user='testing-user' also the second does not show because of the IF statement. It just skips it on to the ELSE statement and echos "0". There is definately a value in the right mysql fields.
  6. Sorry! That means that the echo is always '0' (the else output) However in my database there are columns with exactly the same VARCHARS in these two columns. no mistakes in spelling etc.... no error signs occur. just echoes of '0'!
  7. OK! this is what I have so far!... It is meant to be a sort of referral tracking program! The users have a unique 'code' . All the people they have referred will have the same value as 'code' typed in a column called 'friend' Therefore this program is meant to show a counter of the amount of people referred! - But it is not working! Anyone got any ideas?! Thanks <?php $user = $_COOKIE["user"]; include("db.php"); $user = $_COOKIE["user"]; $cxn = mysqli_connect($host,$username,$password,$database) or die ("couldn't connect to server"); $query = "SELECT code FROM Member WHERE user='$user'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); $nrows = mysqli_num_rows($result); while($row = mysqli_fetch_assoc($result)) { extract($row); } if ($code !=0) { $query = "SELECT * FROM Member WHERE friend='$code'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); $nrows = mysqli_num_rows($result); $referred = $nrows-1; echo "$referred"; } else { echo "0"; } ?>
  8. Hi, I have a very simple problem! I have a mysql database and all i want to do is "SELECT user FROM table WHERE col1='$col2'" and then echo the user names. I, for some reason though am just having trouble getting the data! Any help much appreciated! Thanks
  9. Tried that but it came up with an error "Parse error: syntax error, unexpected T_ARRAY, expecting T_STRING or T_VARIABLE or '$' in .....l.php on line 12" The actual email addresses have to be taken from another table in the database called Member. The two tables history and Member have the columns 'user' in common. This may be something to do with it. Also could you tell me what this part does $recipients = new array(); thanks
  10. Would someone be able to edit my code to make this work?! Or tell me a site I could find out how to do this! Thanks
  11. sorry can you make that a bit simpler for a PHP newbie! What would i need to type in the £email voriable here? --> @mail($email, $subject, $text, $header) thanks
  12. Hi, I have got an array of users using a PHP program. However I am now trying to SELECT email FROM Member WHERE user='$user' Once I have somehow selected all the email addresses I want to be able to send the same email to each of them! The code I have attempted to make so far is.... <?php include("../dbinfo.inc.php"); $cxn = mysqli_connect($host,$username,$password,$database) or die ("Couldn't connect to server."); $game="Chelsea V Liverpool"; ////// MANUALLY CHANGE THE VARIABLE $query = "SELECT DISTINCT user FROM history WHERE game='$game'"; ///////// SELECTS RELEVANT USERS $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); while($row = mysqli_fetch_assoc($result)) /// Take all the results $tsubject = "subject"; $ttext = "text"; $sender = "sender@sender.com"; @mail({$row['user']}, $tsubject, $ttext, "FROM: $sender"); /////////// SENDS EMAIL } ?> The problem I have is somehow putting all the users email addresses in to the line. @mail({$row['user']}, $tsubject, $ttext, "FROM: $sender"); But I dont have a clue how to! Any suggesstions are much appreciated! thanks
  13. I am using this code so that I can send an email to all the users that is associated with the query. Does anyone know how i can send out emails to them all? such as @mail({$row['email']},$subject,$text); thanks
  14. Ah! I have done that but put it in like this.. echo "{$row['user']}"; and it has worked! thanks for the tip. do you know why i could not echo the original? It seems the same to me - I am a newbie to PHP!
  15. I am trying to create an array from a mysql result. At the moment I use the code below and the result turns out to be... Array Array Array Array for the number of users. Can anyone spot my problem? <?php include("../dbinfo.inc.php"); $cxn = mysqli_connect($host,$username,$password,$database) or die ("Couldn't connect to server."); $game="Chelsea V Liverpool"; $query = "SELECT user FROM history WHERE game='$game'"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); while($row = mysqli_fetch_assoc($result)) /// Take all the results { $user[]= $row['user']; echo "$user<br>"; } ?> Thanks
  16. how! great help. too some time to do it but its done! thanks a lot!
  17. I want to be able to create a unique referral code (e.g. FTCGEX3!) for each member - so that they can pass it on to their friends and get commission. Does anyone know of a free script I can download from somewhere on how to create a referral code? many thanks also... can someone tell me how to link up two tables in a database. say if each table had the referral code 'FTCGEX3' i want to be able to SELECT * FROM 'table' WHERE 'refcode'=FTCGEX3. thanks a bunch
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.