Jump to content

liamloveslearning

Members
  • Posts

    758
  • Joined

  • Last visited

    Never

Everything posted by liamloveslearning

  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");
  13. Hi all, Is it possible to store a percentage as a variable? say... var myvariable = 30%; I have a few variables which are going to multiplied by percentages, but im unsure how to do this and cant find much on Google...
  14. Hi all, im trying to set a variable using an if else statement only its breaking my entire code and not executing anything, Can anybody see why? function Calculate() { var ContentMinutes = document.getElementById ("ContentMinutes").value; var ContentMinutesSelect = document.getElementById('ContentMinutesDD').options[document.getElementById('ContentMinutesDD').selectedIndex].value var RenderingHours=20; if (ContentMinutesSelect == 0.0166) { var RenderingHours = 10; var VideoHours = 5; var VideoSeconds = 1; document.getElementById("RenderHours").innerHTML=RenderingHours; document.getElementById("VideoHours").innerHTML=VideoHours; document.getElementById("VideoSeconds").innerHTML=VideoSeconds; } else if (ContentMinutesSelect == 0.0003) { var RenderingHours = 1540; var VideoHours = 54; var VideoSeconds = 1; document.getElementById("RenderHours").innerHTML=RenderingHours; document.getElementById("VideoHours").innerHTML=VideoHours; document.getElementById("VideoSeconds").innerHTML=VideoSeconds; } else { var RenderingHours = 6410; var VideoHours = 345; var VideoSeconds = 124; document.getElementById("RenderHours").innerHTML=RenderingHours; document.getElementById("VideoHours").innerHTML=VideoHours; document.getElementById("VideoSeconds").innerHTML=VideoSeconds; } var NoOfFrames = document.getElementById ("NoOfFrames").value; //var EstimatedCoreHours = document.getElementById ("EstimatedCoreHours").value; var ServiceLevel = document.getElementById('SerivceLevelDD').options[document.getElementById('SerivceLevelDD').selectedIndex].value; var RenderHours = 1; var CoresInTest = document.getElementById ("CoresInTest").value; var EstimatedCoreHours = GetNumeric(NoOfFrames) * GetNumeric(RenderingHours) * GetNumeric(CoresInTest); var EstimatedTotal = GetNumeric(ServiceLevel) * GetNumeric(EstimatedCoreHours); alert('Estimated Cost' +EstimatedTotal); document.getElementById("EstimatedCoreHours").innerHTML=EstimatedCoreHours.toFixed(2); document.getElementById("EstimatedTotal").innerHTML=EstimatedTotal.toFixed(2); document.getElementById("EstimatedCoreHours").style.backgroundColor="yellow"; document.getElementById("EstimatedTotal").style.backgroundColor="yellow"; } function GetNumeric(val) { if (isNaN(parseFloat(val))) { return 0; } return parseFloat(val); }
  15. Hi everybody, Im new to javascript and need some help building a price calculator. Im looking to build something similiar to this http://psdtowp.com/order-now only I've no idea where to start. From applying my own thoughts I was going to set a list of undefined variables which are populated from input fields on keyup, The total would then be calculated on the submit button as I've no idea how to do it on the fly and already im getting stressed out . My current JS is ///////////////////////////////////////////////////////////////////// // Variables // Content/SLA var ContentMinutes = ''; var ContentMinutesSelector; // Switch Case var ServiceLevel = 5; //This is set as a test, it will actually get a value from input var NoOfFrames = ''; // Render Time (Hairier the Better) var AvgFrameRenderTime = ''; var AvgFrameRenderTimeSelector; // Switch Case var CoresInTest = ''; // Other var EstimatedCoreHours = 10; //This is set as a test, it will actually get a value from input // Cost Estimate var CostEstimate = ServiceLevel * EstimatedCoreHours; ///////////////////////////////////////////////////////////////////// // Functions function CalculateEstimate() { parseInt(document.getElementById("PriceEstimate").innerHTML=CostEstimate.toFixed(2)); }
  16. Thinking about it, My variables get their value from an input field on keyup. Could this be the problem? if I set 'var coreHrs = 2' instead of the variables which have no value initially it works fine...
  17. Hi everybody, having a real nightmare with this now, I have 3 variables which take their value onkeyup from input fields on my page, I then need to multiply the 3 and output the total only im returning NaN. my complete page is <html> <head> <script> function functionCalc() { // Variables var conMin = document.getElementById('cMin').value; var serLev = document.getElementById('sLev').value; var coreHrs = noFrames * art * coresTest; var noFrames = 1800; var noFramesTot = noFrames*24; //var renHours = document.getElementById('renHours').value; var coresTest = document.getElementById('coresintest').value; var estCoreHours = 200; // Hours Minutes Seconds variables var avgframerndrtme = document.getElementById('avgrndrtime').value; var secfunc = avgframerndrtme/3600; var secmin = avgframerndrtme/60; var hourfunc = avgframerndrtme/1; var art = document.getElementById('art'); var art_value = art.options[art.selectedIndex].value; var switchart = document.getElementById('switchart').value; // Workout if Average render time is in minutes seconds etc... switch(art_value) { case "minutes": document.getElementById("switchart").value=secmin.toFixed(3); break; case "seconds": document.getElementById("switchart").value=secfunc.toFixed(3); break; case "hours": document.getElementById("switchart").value=hourfunc; break; } var total = coreHrs * serLev; document.getElementById("estDiv").innerHTML=total; alert('noframes ='+noFrames);alert('art ='+switchart);alert('cores ='+coresTest);alert('coreHrs ='+coreHrs); } </script> </head> <body> <h1>Content/SLA</h1> corehours: <input type='text' id='cHours' onKeyUp="functionCalc()" /><br /> content minutes :<input type='text' id='cMin' onKeyUp="functionCalc()" /><br /> Service level: <select onBlur="functionCalc()" onClick="functionCalc()" id="sLev"> <option value="0.84" id="mega">Priority Mega</option> <option value="0.67" id="urgent">Priority Urgent</option> <option value="0.56" id="standard">Standard Job</option> <option value="0.28" id="scheduled">Scheduled Job</option> <option value="0.14" id="lightpass">Light Pass Job</option> </select><br /> number of frames (Optional): <input type='text' id='noFrames' value="1800" /><br /> ---------------------------------------------------------------------------------<br /> <h1>render time</h1> <!--avg frame render hours :<input type='text' id='renHours' onKeyUp="functionCalc()" /><br />--> average render time :<input type='text' id='avgrndrtime' onKeyUp="functionCalc()" onBlur="functionCalc()" /> <select onChange="functionCalc()" onBlur="functionCalc()" id="art"> <option value="hours" id="hours">Hours</option> <option value="minutes" id="mins">Minutes</option> <option value="seconds" id="secs">Seconds</option> </select> <br /> cores in test :<input type='text' id='coresintest' onKeyUp="functionCalc()" /><br /><br /> ---------------------------------------------------------------------------------<br /> <h1>Estimate </h1> estimated Total : <div id="estDiv"></div><br> estimated core hours : <div id="corehours"></div> <br><br><br><br><br><br><br><br><br><br><br><br>AVERAGE FRAME RENDER TIME <input type='text' id='switchart' onKeyUp="functionCalc()" /><br /> </body> </html>
  18. Ahh brilliant, I didnt realise there was an options element. Thanks a lot
  19. I tried defining 'art' as a variable only now its not switching, just alerting me of the variable value... var art = minutes; switch(art) { case "minutes": alert('minutes'); break; case "seconds": alert('seconds'); break; default: alert('hours'); } <select onBlur="functionCalc()" id="art"> <option value="hours" id="hours">Hours</option> <option value="minutes" id="mins">Minutes</option> <option value="seconds" id="secs">Seconds</option> </select>
  20. I havent, sorry to sound naive, first proper javascript page ive written, but would I need to define art?
  21. Hi, Im having trouble with a switch case statement, I've tried using if else too with no luck, In my HTML I have <select onBlur="functionCalc()" id="art"> <option value="hours" id="hours">Hours</option> <option value="minutes" id="mins">Minutes</option> <option value="seconds" id="secs">Seconds</option> </select> and the js in relation to this is // Workout if Average render time is in minutes seconds etc... switch(art) { case minutes: document.write("Finally Friday"); return false; break; case seconds: document.write("Finally seconds"); return false; break; default: document.write("Finally mins"); return false; }
×
×
  • 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.