Jump to content

liamloveslearning

Members
  • Posts

    758
  • Joined

  • Last visited

    Never

About liamloveslearning

  • Birthday 11/25/1987

Contact Methods

  • Website URL
    http://www.liamg.co.uk

Profile Information

  • Gender
    Male
  • Location
    Chester, UK

liamloveslearning's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Ive finally found the problem, Firstly I used 'or die()' to see where I was going wrong (I SHOUDL ALWAYS DO THIS!) I then received the error 'unknown column in where clause' which led me to add '' around my var, the final query is... $qResult= mysql_query("DELETE from user_interests WHERE interest = '" . mysql_real_escape_string($interest) . "' and user_id = " . $usersClass->userID()); if(! $qResult ) { die('Could not delete data: ' . mysql_error()); }
  2. I'vr added or die() which now gives me this Could not delete data: Unknown column 'tenni' in 'where clause' The 'tenni' is a value though, I weant to delete the row that contains the value 'tenni' in the interests column
  3. Hi all, I have a table... ID user_id interest 1 20 football 2 20 tennis 3 20 soccer Im trying to write a function that when the user is logged in, his 3 interests are shown, he then has the option to delete an interest only I cant quite get it to work, can anybody see where im going wrong? Im still a novice with PHP so my code may appear very odd... <?php if(isset($_POST['int1'])) { $interest = $_POST['int1']; $qResult= mysql_query("DELETE " . mysql_real_escape_string($interest) . "FROM user_interests WHERE user_id = " . mysql_real_escape_string($usersClass->userID())); } elseif(isset($_POST['int2'])) { $interest = $_POST['int2']; $qResult= mysql_query("DELETE " . mysql_real_escape_string($interest) . "FROM user_interests WHERE user_id = " . mysql_real_escape_string($usersClass->userID())); } elseif(isset($_POST['int3'])) { $interest = $_POST['int3']; $qResult= mysql_query("DELETE " . mysql_real_escape_string($interest) . "FROM user_interests WHERE user_id = " . mysql_real_escape_string($usersClass->userID())); } print $interest1 . "<form method='post' action='#'><input type='hidden' value='".$interest1."' name='int1' id='int1'/><input type='submit' value='delete' /></form><br />"; print $interest2 . "<form method='post' action='#'><input type='hidden' value='".$interest2."' name='int2' id='int2'/><input type='submit' value='delete' /></form><br />"; print $interest3 . "<form method='post' action='#'><input type='hidden' value='".$interest3."' name='int3' id='int3'/><input type='submit' value='delete' /></form><br />"; ?>[/code[
  4. im trying to call all users from a database with the same interests as the current, logged in user on my website. I have the following // Get Session USER interest $interestsquery = "SELECT `interest` FROM `user_interests` WHERE `user_id` = " . $usersClass->userID(); $result = mysql_query($interestsquery); $interests = array(); while(list($interest) = mysql_fetch_array($result)) $interests[] = $interest; $interest1 = $interests['1']; $interest2 = $interests['2']; $interest3 = $interests['0']; // END INTERESTS //USers with Same Interests $interests_query = "SELECT * FROM produgg_users join user_interests on produgg_users.id = user_interests.user_id where interest = '$interest1' and produgg_users.id != '".$usersClass->userID()."'"; $interests_result = mysql_query($interests_query) or die(mysql_error()); if($interests_result != 0) { while($interests_row = mysql_fetch_array($interests_result, MYSQL_ASSOC)) { echo $interests_row['user_id']; } } else { print "No users to display!"; } //END SAME INTERESTS which doesnt bring back any data, yet if I add (beneath //USers with Same Interests) $interest1 = 'footy'; the interests_query seems to work, can anybody see where im going wrong?
  5. Hi all, i keep receiving error in my mysql syntax for the following query... $Interest1 = "soccer"; $Interest2 = "tenni"; $Interest3 = "footy"; $intres = mysql_query("select * from produgg_users, user_interests where produgg_users.twitterUser != '' and produgg_users.active !='' and produgg_users.credits >= coff and (user_interests.interest = $interest1 OR user_interests.interest = $interest2 OR user_interests.interest = $Interest3) and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY coff DESC LIMIT 30;") or die(mysql_error()); I've been playing with it for the past 30 mins and cant seem to get it to work, can anybody see obvious errors? Thanks
  6. I have a function on my website where users can enter their interests and the information is stored in a DB, this is all done via AJAX. My insert script is the following <?php require 'config.inc.php'; ?> <!-- Verify if user exists for login --> <?php if(isset($_GET['useridint']) && isset($_GET['interest'])){ $url= mysql_real_escape_string($_GET['useridint']); $sitename= mysql_real_escape_string($_GET['interest']); $insertSite_sql = "INSERT INTO user_interests (user_id, interest) VALUES('{$url}' , '{$sitename}')"; $insertSite= mysql_query($insertSite_sql) or die(mysql_error()); echo $sitename; } else { echo 'Error! Please fill all fileds!'; } ?> Is it possible I can limit the number of entries into the DB each user can have? So user X can only enter 3 interests as opposed to hundreds? Thanks in advance!
  7. Hi all, I have a small user community website ~250 users, and I want to add a section where they can enter there interests. Users can enter their interests manually, So user X will add Tennis, Football, Basketball. If user Y then goes to enter his, as hes typing I want a script to check the DB to see if theres any possible values that match, so if he type FOO football would appear. My idea is that after X months the table will have plenty of options and most interests will be auto completed. What im asking is how is the best way to do this? Does this make sense?
  8. Hi all . Im trying to have a query run if a post variable is set, I have the following code only its not working can anybody see something im missing? if(isset($_POST['r']) { $refcode = mysql_real_escape_string($_POST['r']); mysql_query(" UPDATE produgg_users SET credits=credits+200000 where produgg_users.id = ".$refcode) or die(mysql_error(); };
  9. Thanks Alfa, I already have something like that, the process needs to happen after the user has registered however; Im thinking after they register they can be passed to a similar page where the query happens
  10. Hi, Im about to start building a referral system for my website only im struggling to get my head around the theory first, my website is credit based so for every user you get signed up you receive X credits... I plan on the following... Say user X has the referral link http://www.mysite.com/referral.php?ref=123 When somebody visits referral.php, a query is run and adds 10 credits to the user whose ref = 123. My only problem is I need it to only run the query if they visit the referral link, and then regsiter. Sorry if this is confusing, any input would be great, thanks
  11. Hi all, not sure if this belongs in the Javascript section or PHP... I have a 3 pages, Index.php, a Javascript file and my display.php page. My Index page has a list of inputs which populate the variables in my javascript file when exectued, the javascript file then uses these variables to perform simple mathematical calculations and then displays the data using the innerHTML function back on my index page. From the index page I need to then post all my values, including these in the innerHTML div's as a POST array to my display.php only im unsure where to start. Hopefully thaat makes sense, would anybody have any idea on how to do this? Thanks
  12. Hope this isnt a stupid question, but to store them as floats is it simply a case of var myvariable = parseFloat(".27");
×
×
  • 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.