Jump to content

AyKay47

Members
  • Posts

    3,281
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by AyKay47

  1. I think you are over complicating this. First, to remove any tags found in the string, you can simply use strip_tags which will leav you with the content inside of the tags. Then you can do any other sanitization you want.
  2. Well, scootstah broadly answered your last inquiry: I would be curious to know how PHPFreaks does things too.. PHPFreaks uses SMF, if you research SMF you will understand how this website is set up. But to your questions, this kind of database set up is more of a common sense ordeal than anything else really. The normalization here depends on the private message logic (what features you want to have incorporated in the PM functionality.) I see that you have already thought about the features and have laid them out, this is good. Private Message: - id - sender_id - recipient_id - subject - body - sent_on - new_message_status (recipient) - recipient_read_status (sender) - sender_deleted_status (sender) - recipient_deleted_status (recipient) - recipient_responded_status (sender)(recipient) You never want to have too many fields in a single table that aren't necessary for the core functionality and can increase dependency. In your case, given the data in this thread, I would break this into 2 (or possibly more) tables. I would have the core private message data in one table: - id - sender_id - recipient_id - subject - body - sent_on The above data is the essential data needed for a message, the other data is simply nice features that are not needed in the main table. so the second table: - new_message_status (recipient) - recipient_read_status (sender) - sender_deleted_status (sender) - recipient_deleted_status (recipient) - recipient_responded_status (sender)(recipient) Of course, there would be a few relations needed to link the first and second tables: 1. the message id 2. the recipient id 3. the sender id The "message id" would be the primary key (pk) and would link to the `id` field in the first table. The other two fields would be foreign keys (fk's) linking to the recipient and sender id's respectfully. I might even break the second table into smaller tables separating them by each individual functionality to simplify things even further, but I will leave this up to you to decide.
  3. It doesn't need to be, you will generate the full name using PHP, something like what dragon_sa suggested. the code will then be: $firstname = $_POST['firstname']; $middleinitial= $_POST['middleinitial']; $lastname= $_POST['lastname']; $full_name = "$firstname $middleinitial $lastname"; $sql = "INSERT INTO myTable ( FULL_NAME ) VALUES ( $full_name )"; $result = mysql_query($sql); But typically, for greater database flexibility, you would separate each part of the name into 3 separate fields. So you would have `first_name`, `middle_initial` and `last_name` fields. Then when grabbing the data vie select statement, use CONCAT_WS() to alias all three columns into a full_name result.
  4. It would help if you showed the actual results after the "clean" function is ran on $raw.
  5. 1. each language should be kept separate and you should avoid intermingling them (IMO). 2. My advice would be to run any sort of validation using PHP and not JavaScript, as JavaScript can simply be disabled. 3. I normally always link to an external .js page which holds all of the JavaScript code, to keep it away from the design and PHP business layers.
  6. Does $_SESSION['returnToPage'] simply hold the http_referer? A switch is the way to go for this I believe, to compare multiple values against the session value. darkfreaks was close, however the switch syntax is a little off: $returnToPage = null; switch($_SESSION['returnToPage']) { case 'members/my_account.php': $returnToPage = '/index.php'; break; default: $returnToPage = $_SESSION['returnToPage']; break; } You will add new cases for each referer that you do not want to set $returnToPage to the session value. The default condition will trigger if the session value does not equal any case values. You can (should?) add the switch into an if statement checking for the session being set first.
  7. 1. passing parenthesis into a function is pointless, as the display can be handled with PHP after the function has returned the necessary data. 2. If you simply want to check for a variable being empty, use the empty function that PHP provides.
  8. Depends how the user is getting to index.php, do they need to login? More info is needed, and some code would help.
  9. What errors are you receiving?
  10. If there are multiple text fields that a user can specify an order, than using an array name is fine, and the foreach is fine. However you certainly do not want a foreach loop inside of a while loop, and running queries each iteration at that. This can be done with one query using only the foreach loop. foreach($_POST['order_by'] as $order_by) { $sql = "UPDATE source_subject SET order_by = '$order_by' WHERE subject_id = '$subject_id' AND source_id IN (select source_id from table)"; //replace 'table' with whatever table the column is supposed to come from. }
  11. Awesome, this should be cool..
  12. Ah, i forgot to include the braces, I'm going to QQ in a corner. Array indices inside of double quotes need those braces to be interpolated correctly.
  13. well, the code you posted backs up what I stated. Glad you got it.
  14. see what a view source shows.
  15. I'm going to take a stab at this one, not 100% sure. I believe the error is happening because the object that you are creating inside of the function is not available outside of its scope. Try passing the form object into the function via is argument list.
  16. "<a href=\"detail.php?id_item=$row_texts_RS['id_item']\"> ... read more</a>"
  17. globals should never be used. They can cause variable pollution and completely break the encapsulation of a class/function. If you need access to a variable in the global scope, pass it through the argument list. I still do not understand the issue.
  18. problem lies here: '<a href="detail.php?id_item=$row_texts_RS['id_item']"> ... read more</a>' variables are not interpolated within single quotes, either switch to double quotes or use concatenation.
  19. because you have already broken out of the case.
  20. $("#rating a").css('background-color', '#999');
  21. If you want to grab multiple rows, then generate the query in a way that it will grab multiple rows.
  22. Yeah, I failed. select distinct u1.id as type_1, count(id) as count, u2.id as type_2 left join users as u2 on (u2.type = 2) from users as u1 where u1.type = 1;
  23. Probably some kind of recurring loop issue. Post the code.
  24. You are not using a join you are using a union. Do you know what you are actually doing by setting @x:= to a field? Because you immediately overwrite the value that you set. If you are not sure if one of these values will return a result set, use a join or subquery. select distinct `type 1 users` as type_1, count(id) as count, (select distinct `type 2 users` from users where type = 2) as type_2 where type = 1; *This query is untested, may need tweaked*
  25. $a = array(01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11); $a_w = array_walk($a, function($v,$k) use(&$a) { ltrim($v, 0); }); if($a_w) { print_r($a); } results: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 0 [8] => 0 [9] => 10 [10] => 11 ) This is pseudo code, I'm sure a better way exists, but I'm having a brain fart.
×
×
  • 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.