Jump to content

master82

Members
  • Posts

    182
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

master82's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  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?)
×
×
  • 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.