Jump to content

djlee

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by djlee

  1. if there not having to sign up to your system to vote, then yes the IP is probably the best option. You need a way of uniquely identifying someone. while ip's aren't really unique and can be spoofed/changed easily, its your best option unless you require registrations. You could also include other things like setting a cookie or session with a long timeout on it. While its easy enough to delete the cookie, it just adds an additional layer to the system to be circumvented. Apply a few more other layers that you can come up with and then settle with what you have. A good idea may be to have a captcha code for voting, either for everyone or placed randomly. If you did it for all votes, then people would get bored of spamming quite quickly, however it could deter legitimate users. Really its up to you to decide thos elayers based on your system and its intended audience
  2. his source files are wrong, product_list isnt defined anywhere, so either he has shared the wrong files or he never actually successfully finished what he was doing. I've given you an example of how to "do this yourself". product list seems to just be the html output. So within the while loop that gets the products, just keep adding to a product_list variable, the html output yoyu want to see
  3. i cant see the video, but basically, an undefined variable means exactly that. Theres no hidden secrets. Your trying to use a variable that hasnt been defined. Looking at your code you do not create and assign a value to that variable anywhere. The product list looks like it should be a variable containing the html to be outputted into the list. I suggest you go back through the video and find out where this is defined and how. the product list will most likely be defined above the while loop and then appended to within the while loop with each product. change // Gather this product's full information for inserting automatically into the edit form below on page if (isset($_GET['pid'])) { $targetID = $_GET['pid']; $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $product_name = $row["product_name"]; $price = $row["price"]; $category = $row["category"]; $subcategory = $row["subcategory"]; $details = $row["details"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); } } else { echo "Sorry dude that crap dont exist."; exit(); } } to // Gather this product's full information for inserting automatically into the edit form below on page if (isset($_GET['pid'])) { $product_list = ""; $targetID = $_GET['pid']; $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $product_name = $row["product_name"]; $price = $row["price"]; $category = $row["category"]; $subcategory = $row["subcategory"]; $details = $row["details"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $product_list .= $row["product_name"]."<br />"; } } else { echo "Sorry dude that crap dont exist."; exit(); } } to see what i mean
  4. its for windows, you could run it under wine, its not as if you need it constantly. If you dont like wine you can probably find a mac regex builder, but i tried loads of builders for windows and i found expresso to be the best one. Personally preference i guess. What do you mean by wildcard ? The * just means match any, so it will match href "" as well as href="really long string" . You could have used ".+?" and that would have meant "one or more" but if the href was ever empty, it wouldnt match anything. I guess it depends on what your actually trying to accomplish. If by "find out what wildcard matched" you mean return the contents of href, then preg_match would do that. Not sure if theres a return matches in preg_replace, you'd have to check the php docs, its something ive never required to do so im not sure if theres a flag in the function for this or not Hopefully that makes some sort of sense
  5. A quick and dirty regex like /<base\s*href=[\"\'](.*?)[\"\']>/is will match the contents of href so you can replace it. " .* " is a greedy expression that basically means select everything possible. " ? " defines as few as possible (so it will match only up to the first quote is finds, need this otherwise it wil match up to the last quote which could be 1000 lines down the script such as many strings of "> exist usually) Get yourself a copy of expresso, it did me wonders learning regex with it.
  6. theres a number of ways of doing this. Im guessing you do not want the page to refresh (if you did, you could just pass a get or post param on page load and show whichever query result was requested). So you will have to do it via javascript (basically, if you want to update page contents without refreshing the page, then this is the way to do it). The easiest way is to print out both query results into a wrapper (i use divs) then assign a id or class to each div, then when select changes, show the div that you need. I dont remember a lot of javascript since i started using jquery, so i cant provide exact code example, however heres a link to an example i made up that uses the jquery javascript library. If you dont use jquery, then you'll have to google for the relative "raw" javascript versions. http://jsfiddle.net/FMatc/1/ You can see the result in the bottom right box. The javascript code can be condensed and made to work more dynamically but ive made the javascript bulky so its easier for you to follow the flow and how it works
  7. echo '<table><form method="post" action="update.php" onsubmit="return udpate()">'; the function name in the onsubmit is wrong
  8. the get display div that is populated is outside of your form tags. therefore the submit is outside your form tags when the html is inserted. I'd imagine thats the issue ?
  9. a little late probably, but what i'd look into doing first is looking at the various CLI ftp clients. see if you can make a php communication function (or class if you like your OOP). Then use system/exec/e.c.t. calls to fire up the ftp client, add the files to its queue and then it will just work in background. Ofcourse this is dependant on finding a good cli ftp client but its the first thing that came to mind when reading your post. Theres many other ways you could look at. Use php cli to do the heavy lifting on the backend for example would probably be an easier solution. then just make a crontab entry on a php file that checks if all the files have been sent successfully, if not then try again.
  10. Unless theres a way of passing the array key's through aswell then you've pretty much got to do as suggested and search through it manually. But that wouldn't be very reliable or secure for that fact. The only other thing you could do is maintain an array of pointers. I imagine you generate the array dynamically. so Yafter creating the array of which you need a ponter to its values you could do something like $pointers[$array['id']] = &$sectionArray[1]['subSections'][0]; This would be created whenever you add an array containing a label,id and checkvalue. and the first and second array keys [1] and [0] in the example, would be found from the current loop that populates the main array. Because there simply pointers you can just then do $id = "techAssist_laymanExp"; //-- passed from form $pointers[$id]['checkValue']=true; I like the pointers way as i tend to think that creating a second array on initialisation of the code is better and more "future proof" in regards to performance than looping. However its not suitable in all applications, really just depends on how your array is generated [/code]
  11. Where is uservals being set ?
  12. cant find an edit button so just to let u kno i sorted it select count(*)+1 from (select count(*) from table group by fieldB having sum(fieldA) > (select sum(fieldA) from table where fieldB=24)) rank;
  13. im usually terrible at off the top of my head coding examples but we'll see, how does this work $res = mysql_query("SELECT date, COUNT(host) AS rowtotal FROM `tablename` GROUP BY date ORDER BY rowtotal DESC LIMIT 30"); echo "<table>"; while($arr = mysql_fetch_assoc($res)) { echo "<tr><td>".$arr['date']."</td><td>".$arr['rowtotal']."</td></tr>"; } echo "</table>";
  14. Hi, thanks for the reply but that thread is basically aiming towards my first sql statement i posted, where it selects a rank (that thread also gets other fields but i dont need that bit) depending upon the value of a single field. What i need to do is select the rank depending upon the sum of a field as there will be multiple entries for each user. I tried that middle query without the group by and i get the "invalid use of group function" error. Also before anyone tells me to do so, i cannot just keep updating fieldA with new data in order to use the first SQL i posted as each record also contains unique data in other fields used by other systems. I may be able to get around it with a loop but with the almost definate chance of this table growing into thousands of records i was looking for a single SQL statement to be much more efficient than a loop which would use at least one extra query per uid. Thanks for the reply though, every reply hopefully gets me closer to an answer
  15. Weird... and theres no opendir error ? maybe try while(($file = readdir($handle1) !== false) im just shooting into the dark though since i cant find anything else in that part of the code that i think is "bad" apart from $tmp_folder = $_POST['temp_folder']; $con_fold = "$tmp_folder"; would it not be better to just assign the con_fold directly to the POSTed variable as ur doing nothing but duplicating the data in the variable (doubling the RAM space that data holds, not a lot but hey im all for optimisation lol)
  16. Some browser engines simply like to ignore styles on empty cells (an older version of FF used to do it not that i ever experienced it). Sometimes the best thing to do is just insert in empty cells, which to a browser is valid text and should format correctly. But as samshel said, post the code you've done and someone will be able to provide a much clearer answer
  17. Ok this is the code ive been working from. This is what i created to get the "rank" of a user depending upon a select field (uid example used, i obviously have a variable there) SELECT count(*) FROM players WHERE score >= (SELECT score FROM players WHERE uid=44 LIMIT 1) problem is i am now working on a different sub-system where there are multiple records for each UID, i need to get the rank depending upon the sum of a field. Now im no MySQL expert, i only learned what ive needed in order to do what i do up to this point where im stumped. So i first tried SELECT count(*) FROM players WHERE sum(fieldA) >= (SELECT sum(fieldA) FROM players WHERE uid=44 LIMIT 1) GROUP BY uid I obviously got a error about invalid use of grouping. but i posted that there as i think it gives the best explaination of what im trying to do, after this i tried SELECT count(*) FROM players GROUP BY uid HAVING sum(fieldA) >= (SELECT sum(fieldA) FROM players WHERE uid=44 LIMIT 1) While i got no errors, that returned a resultset thats incorrect, on one test uid it returned a single count(*) which at that point i was overjoyed of course, but then with another uid it returned a resultset of 3, which obviously isnt correct as i only shud have one in the resultset (the rank number) Does anyone know where im going wrong, can someone help me out ?? Any help would be greately appreciated
×
×
  • 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.