Jump to content

master82

Members
  • Posts

    182
  • Joined

  • Last visited

    Never

Everything posted by master82

  1. I have done (group by code) but that also shows every user who does have a code to themselves. Creating a long list! What i need (if possible) is to see ONLY those users who have the same code as another user, with the code they were given eg see Mr X with code 12345 and Mr Y with code 12345 but not Ms Z with code 54321 hope im explaining this right?
  2. I have a table that consists of 6 fields tableid - unique auto incremental value code - a code given to each user userid - the unique id of the user time - unix timestamp of when the code was issued ip - the ip of the user when code was issued status - small description of why the code was given Now what I need to do is identify all the userids that appear with the same code only and list them, so that i can see if the same code is in use by multiple users. I know its probably something simple, but im having an off day Any help would be greatful
  3. Here is the code I am attempting to use, I have checked all the tables names, fieldnames and have even looked to see if they contained data... <?php $ud=mysql_query("SELECT `users`.`usersNAME`, `worth`.`worthMONEY FROM `users` WHERE `users`.`usersID` = '{$userid}' INNER JOIN `worth` ON `users`.`usersID` = `worth`.`worthID`") or die(mysql_error()); $u=mysql_fetch_assoc($ud); ?> However, I get the following output: Any ideas as to where im going wrong?
  4. Thank you... You are all stars! Lastly, before I go make changes.... Is it better to combine them, or would having them seperate be better? (maybe reducing the number of connections saves on server CPU?)
  5. so for 3 tables... <?php mysql_query("SELECT `table1`.`col1`, `table1`.`col2, `table2`.`col1, 'table3`.`col2 FROM `table1` WHERE `table1`.`userid` = '{$_SESSION['userid']}' INNER JOIN `table2` ON `table1`.`userid` = `table2`.`userid` INNER JOIN `table3` ON `table1`.`userid` = `table3`.`userid`"); ?> ??? i only ask as I have about 5 different tables that can make up some pages, currently using 5 different queries to obtain the values using the same unique userid field in each
  6. Yes I currently have several queries.... Note the session stores the unique users id obtained from logging in $ud=mysql_query("SELECT userid, username, bla bla bla FROM users WHERE userid = '{$_SESSION['userid']}'"); $user=mysql_fetch_assoc($ud); $wd=mysql_query("SELECT userid, points, bla bla bla FROM wealth WHERE userid = '{$_SESSION['userid']}'"); $wealth=mysql_fetch_assoc($wd); print"Welcome {$user['username']} you currently have {$wealth['points']} points available to use today"; Thats just a quick example...
  7. I have several SELECT queries on a few of my webpages, and I have been told that the more query connections that are open the slower the server will run. So firstly, is it possible to merge/combine 2 SELECT queries into a single query? Current I use 2 or more like below: $a=mysql_query=("SELECT fields FROM table WHERE userid = '{$_SESSION['userid']}'"); $aa=mysql_fetch_assoc($a); $b=mysql_query=("SELECT fields FROM table WHERE userid = '{$_SESSION['userid']}'"); $bb=mysql_fetch_assoc($b); //then print the values within the page where needed print $aa['field']; print $bb['field']; can they be combined? maybe something such as below (except im not sure about the WHERE statement) $a=mysql_query("SELECT a.fieild, b.field FROM a.table, b.table WHERE a.userid = '{$_SESSION['userid']}', b.userid = '{$_SESSION['userid']}'"); $aa=mysql_fetch_assoc($a); //print values when needed print $aa['a.field'] //although im sure i dont need the a. above, and with both tables having different field names there should be no name conflict And secondly, if the above is possible, would this reduce the number of connections to the SQL database and therefore save some of the servers resources?
  8. or just add unix_timestamp() to the insert / update query if you want the current time it was inserted / updated
  9. Would they allow me to place the array into another select query (in the where part) later on, or cant you place an array into such queries?
  10. I need to create an array from a list of IDs within a database table. The table consists of 3 fileds, a unique ID, a user ID and the last is an int value (item number) eg 1 3 7 2 4 5 3 3 2 etc... How would I go about using this query $query1=mysql_query("SELECT itemnumber FROM table WHERE userid = '{$user}'"); Would i be right in thinking I can use: $array = mysql_fetch_array($query1); to store all the item numbers associated with the user specified in the first query?
  11. lol Simple things.... Thanks!
  12. I have created the following function in function.php <?php function igm($text) { //remove links $text = preg_replace("#www\.(.+?)\.com#is", "link here removed", $text); //remove unwanted characters $text = preg_replace("/[^a-zA-Z0-9.!?, ]/", "", $text); return $text; } ?> I then want to use this function on a user input before it is stored in the database, so I am doing the following... <?php include("function.php"); igm($_POST['userinputfield']); mysql_query("insert here"); ?> However it doesnt seem to be working, any idea why not or advice? Thanks
  13. Thanks, I dont know any JS so didnt know how to test these things...
  14. Just a quick question... If I use htmlspecialchars on a user text input before storing into a database, then when showing the data in an output use htmlspecialchars_decode before displaying, would that allow potentially harmful code to be run? (ie is it only a good way to store the data not display it?)
  15. Sorry, didnt see the code you added... thought it was just my original code lol
  16. Thats the exact website I got the code above from a few months ago, but it doesnt say anything about keeping spaces, commers, fullstops, and i guess even brackets in the variable. (at least not what I can find) And all the google searches I have come accross always use date examples which also doesnt help
  17. I have a small mail system for my site, however I need to sanatise any use input... I an familiar with: <?php $output = preg_replace("/[^a-zA-Z0-9s]/", "", $input); ?> to restrict the input to text and numbers only, however, I need to also allow spaces, dots and commers. So could somebody help me add these into this? Thanks
  18. Not sure where to start with this, What I am hoping to do is create a simple form to securly upload an image file into a specific folder in the root of my site directory (folder: upics). I also need it to rename the image to user(userid here) [eg user1234.jpg]. But if that file already exists, then to simply overite it. Is this possible? And if so, where should I start?
  19. master82

    PEAR

    Ive searched the net and didnt find anything of help, so... ...can someone please explain (in a simple way) just how pear fits into php? Also, is it worth trying to learn, if so any useful sites as to where i can get started? Thanks in advance!
  20. Im currently looking for a php script that i can use that will allow me to parse data from my sql database into a safe output. I have searched around and found basic ones, such as text formatting, but what I require is a way to provide images, flash, music etc WHILE sanatising the data to get rid of security holes (XSS or what ever it is). Does anyone know where I can obtain one? (I could try to code one myself, but my current time is limited )
  21. Is it possible to remove certain text from an input before it is stored in the database? I have a lot of people spamming my site with their own sites... i have already removed thr www. and com co.uk etc but it still doesnt stop people guessing. So is it possible to remove everything between www. and .com for example? ie replace www.sitehere.com with -removed-
  22. If I use... $id = mysql_insert_id() ...after the 1st inser query then use $id in the 2nd insert query. Would that work?
  23. Thats how it is set up... just not sure how to get that id! lol mysql_insert_id() How do I use that? I think that is my answer
  24. I have a simple authentication script, when details are checked a new user is entered into two different tables in the database... mysql_query("INSERT INTO members ('mid', 'memail', 'mcode', 'mpassword', 'msignup', 'mlastip', 'mgender', 'mlaston') VALUES ('', '{$_POST['email']}', '$unique', md5($_POST['password']), UNIX_TIMESTAMP(), '$IP', '{$_POST['gender']}', UNIX_TIMESTAMP())"); mysql_query("INSERT INTO users ('uid', 'uname', 'ugender') VALUES ('NEEDidHERE', '{$_POST['name']}', '{$_POST['gender']}')"); The members table has an auto-incremental setting for 'mid'. My question is how do I edit the code above so that I can insert that unique member id into the unique field of the second table (uid -> NEEDidHERE)?
×
×
  • 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.