Jump to content

stevew

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by stevew

  1. Sorry..it is for a messaging system...after some thought since my last post...instead of duplicating the data for the purpose of allowing users to track sent messages I am now using boolean values in the same table to track when a user has "deleted" a message from their inbox or outbox and display accordingly. Thanks for pointing me in the right redirection.
  2. Its ok nm....I realized what you meant after posting and have updated....two INSERTS executing in the same query is all I needed.
  3. Yes, I was referring to passwords. Got it thanks.
  4. I need both id values to mirror each other so I can query them from either table and get the same data. Can I depend on a double INSERT like below or should I set up a trigger? mysql_query("INSERT INTO tb1 (id,value2,value3) VALUES ('$id','$val2','$val3')"); mysql_query("INSERT INTO tb2 (id,value2,value3) VALUES ('$id','$val2','$val3')"); On a side note, would appreciate some comments regarding what kind of hashing to implement. md5 with salt, sha1 with salt, crypt(), hash()........ thx
  5. Ha ha...thanks but fortunately I learned this lesson the wrong way myself! P.S. WHERE FIND_IN_SET(88, theField); thx
  6. We are using usernames not names so no duplicates...although I may switch over to id anyway for messages. WHERE name LIKE '$name' && datesent>logoutdate ORDER by ASC datesent"; This is in the messages SELECT statement but I omitted the comparison from the JOIN statement initially while tesing. The message notification is working as intended as two separate SELECT statements...so I will leave it as is until I can figure this particular JOIN out. Thanks.
  7. but $sql="SELECT messages.datesent, users.logoutdate FROM users LEFT JOIN messages ON users.name = messages.name WHERE users.name = $name ORDER by ASC datesent"; The issue still remains that when I use separate SELECT statements as in my original post it returns both results...but the JOIN still does not.
  8. 1. I use name as the unique id because to pair the messages to "joe smith" in messages.name to user 'joe smith' in users.name. but I suppose I could INSERT user_id instead of name.
  9. I plan to use upon login: if ($datesent>$logoutdate){ echo "you have new messages"; } 4. Yes...each user will only have one logout date in users.logoutdate however, users will have multiple rows in messages.name,datesent etc as they will receive multiple messages from other users. 1. I use name as the unique id because to pair the messages to "joe smith" in messages.name to user 'joe smith' in users.name. but I supposeI could INSERT user_id of the sender instead of the name, and then just use where messages.user_id = users.id..... 2. will experiment. 3. thx P.S I would prefer return all the matching rows from messages.datesent so I can then use: $numrows = mysql_num_rows($sql); print"you have $numrows new messages etc...";
  10. I would like to join these two SELECT statements into one. $sql="SELECT logoutdate FROM users WHERE name LIKE '$name'"; $result=mysql_query($sql); while ($rows = mysql_fetch_assoc($result)){ $logoutdate=$rows['logoutdate']; } 2012-10-12 07:25:22 $sql="SELECT datesent FROM messages WHERE name LIKE '$name' ORDER by ASC datesent"; $result=mysql_query($sql); while ($rows = mysql_fetch_assoc($result)){ $datesent=$rows['datesent']; } 2012-10-12 07:20:39 This is my attempt...but it does not return the users.logoutdate $sql="SELECT messages.datesent, users.logoutdate ON messages,users WHERE messages.name=users.name ORDER by ASC datesent"; $result=mysql_query($sql); while ($rows = mysql_fetch_assoc($result)){ $datesent=$rows['datesent']; $logoutdate=$rows['logoutdate']; } 2012-10-12 07:20:39
  11. There is something to be said about understanding why the wrong way is wrong and simply knowing the right way.
  12. Thanks <?php $var='1.jpg'; $tmpfile ="images/"."$var"; unlink($tmpfile); ?> Works great.
  13. Using xampp environment. I am trying to delete a file with the unlink function using a variable in the path. When I try to use $var I get the permissions error: <?php $var='1.jpg'; $tmpfile ='images/'?><?php echo $var; unlink($tmpfile); ?> 1.jpg Warning: unlink(images/): Permission denied in C:\xampp\htdocs\xampp\..... on line 3 However this way works fine: <?php $tmpfile ='images/2.jpg'; unlink($tmpfile); ?> 2.jpg is deleted successfully from the 'images' folder. Any help appreciated thx.
  14. <option value="%">all</option> Got it working with the % value. ID*********apples*********oranges**********bananas 1***********yes************yes*************yes 2***********no*************yes*************yes 3***********no*************yes**************no $apples "all" $oranges "yes" $bananas "yes" result: rows 1,2.
  15. Ok I have switched to dropdown select for now. This basic example working properly. <FORM METHOD=POST ACTION=""> <select name="Check1"> <option value="all">all</option> <option value="yes">yes</option> <option value="no">no</option></select> <select name="Check2"> <option value="all">all</option> <option value="yes">yes</option> <option value="no">no</option></select> <select name="Check3"> <option value="all">all</option> <option value="yes">yes</option> <option value="no">no</option></select> <INPUT TYPE=SUBMIT VALUE="Submit"> $apples = $_POST["Check1"]; $oranges = $_POST["Check2"]; $bananas = $_POST["Check3"]; $result = mysql_query("SELECT * FROM fruits WHERE apples like '$apples' && oranges like '$oranges' && bananas like '$bananas'"); How do I tweak this to make use of the "all" value? ID*********apples*********oranges**********bananas 1***********yes************yes*************yes 2***********no*************yes**************yes 3***********no*************yes**************no $apples "all" $oranges "yes" $bananas "yes" the query should return rows 1,2. thanks
  16. Ok thanks...a rewrite is no problem as just trying different things out. I will familiarize myself more on the different relationships and joining tables.
  17. Yes...that is the intention. The problem I am having is how to create a select statement that will query multiple columns in the same table. SELECT * FROM fruits WHERE apples, oranges, bananas like '%$fruits%'");
  18. Thanks but I am looking to use LIKE $fruits in the SELECT as the values are going to be different every time. Anyway, I am going to create a separate column for each fruit.
  19. (Checkboxes) apples oranges bananas I have imploded the form input into a string ($fruits) so whichever boxes are checked will return those results in a string. The SELECT FROM table has a 'fruits' column with various combinations of the $fruits strings. Everything works properly except for the following query: apples,bananas Ideally, this should return any rows that contain apples,bananas, & apples,oranges,bananas in the 'fruits' column...just as apples,oranges will also return rows with apples,oranges,bananas.
  20. Got it thanks. Ya, I noticed it seemed redundant () but was only using as an example. Thanks again
  21. Thank you. How do I require it more than "once"? ie once in footer.php and once in header.php?
  22. functions.php <?php function copyright(){ echo "July 30, 2012<br />"; } ?> <?php { echo copyright(); } Result: July 30, 2012 How would I call this function from say footer.php?
  23. These are the current privileges: User Host Type Privileges Grant Action root linux global ALL PRIVILEGES Yes Edit Privileges root localhost global ALL PRIVILEGES Yes Edit Privileges All boxes are checked.
×
×
  • 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.