Jump to content
Larry Ullman's Book Forums

Antonio Conte

Members
  • Content Count

    1084
  • Joined

  • Last visited

  • Days Won

    126

Everything posted by Antonio Conte

  1. Best idea in my head by a mile. Seem "the right way" to do what you want. It'll also be correct without a stylesheet. The only reason why I've given this some thought, is that I find it interesting myself. As with you, I couldn't see a good easy way to do this.
  2. I don't know but how about something like content: "<" in CSS? I don't know, but the only other thing I can think of. http://htmldog.com/r...erties/content/ Btw. Html-comment is not a bad idea. Tried &<!--comment-->lt; ?
  3. A little CSS-hacking perhaps? HTML: &<span class="hide">.</span>lt; CSS: span.hide { display: none; // possibly more code. } < will always be encoded to < by the browser I think. This method might work because it's split up by punctuation. Not tested though Edit: If the text does not need to be markable by mouse/etc, you might just use a picture?
  4. Hey, I'm not sure how T-SQL works. In MySqli, we don't define foreign keys in the table structure - we do it in our queries. I don't know how the structure for table "non_coffee_products" is. The columns in the SELECT statement is just made up by me. SELECT product.id, product.name, category.name FROM non_coffee_products AS product INNER JOIN non_coffee_categories AS category ON (product.category_id = category.id) I don't know if T-SQL has Inner Joins, but I'm guessing they do. Hope it makes sense. Several FROM tables and a WHERE clause might also work if you don't need category names etc.
  5. I like to use three different HTML inputs for dates. It just makes it easier to prevent date mistakes in my head. I also like to use jQuery to dispay DD / MM / YYYY in the field before click. Use the function checkdate. It will not accept anything but integers and correct dates. (30. february is giving faluire.) This function is relying on it. <?php function dateCheck($day, $month, $year) { if ( checkdate((int)$_POST[$month], (int)$_POST[$day], (int)$_POST[$year]) ) { return $date = $_POST[$year].-$_POST[$month].-$_POST[$day]; } else { // error handling } } ?> To work with numbers FROM the database, use something like substring. $day = substr("$row['dato']", 8, 2); $month = substr("$row['dato']", 5, 2); $year = substr("$row['dato']", 0, 4);
  6. I'm glad it worked, because it was only an uneducated guess
  7. Jibaba: Use mysql_real_escape_string() instead of mysql_real_string() The function needs two parameters: One is your database connection. The other is the string you want to clean. Example: <?php $wash-me = "I might have dangerous data inside me!"; $clean = mysql_real_escape_string($wash-me, $database-connection); ?> Now you can use $clean to put data safe into a database.
  8. I haven't tried this, but try adding more parameters to the function. <?php $command = "/Applications/MAMP/htdocs/bin/pdftotext -f 1 -l 1 "; exec ($command . $pdf_filename . ".pdf " . $pdf_filename . "1.txt", $return_array, TRUE); foreach ($return_array as $output) { echo $output; } ?>
  9. category (id, name) 1 / Category 1 2 / Sub 2 3 / Category 3 three (id, parent*) 1 / 0 2 / 1 3 / 0 Result: Category 1 ---> Sub 2 Category 3 ------------------- Underlined: Primary key Asterix: Foreign key
  10. By looking at the manual, try something like this. (You will of course need to modify table names, etc) NB: Remember to backup table if you want to keep the data safe! DELETE users, comments FROM users INNER JOIN comments ON (users.id = comments.user_id) WHERE users.id = {$user_id}
  11. I've seen that many struggles with more advanced SQL-queries. I've thought about writing a long post about queries, but where does one start? Mysqli is so full of functionality, but very little of it is normally used by PHP users. We like to manipulate data with PHP, often making things a lot harder for ourselves. Thank you for the nice words, Jonathon. I've written on UK and English board since I was 12-13 years old, and it's been great practice for me.
  12. I'm not 100% sure of this. It matters in how the data is presented to you in SQL. It does not matter with PHP, as you specify which columns you would like to display, and how you would like to display them. Yes, you are absolutely right. Inner joins does not filter data. It connects data. That is how you would want to look at it. Regarding your question: Think of the columns vertically. Another Inner Join will add columns to the right of the column that you are joining on. Coffee_id: 13 / Size: 0.5 (kilo) / Height: 17 (cm) / etc. Are you following? And I did not read this before I answered your last quote. English is not my primary language, but this sounds more like the correct explanation of what happens. Arrest me if I'm wrong. As stated earlier, I think this will produce the same result. I cannot absolutely guarantee it, but why not do a test in phpMyAdmin or something? Correctamento. ORDER BY, order by, order BY, ORDER by... It does not matter. But you should really make it easier to write your queries. Larry has limited space, but you should make it easy to read. Look at something like this: Isn't this just WAAAY more simple to read? I've changed you names a lot here, but have tried to keep it logical. Hope you are get something from this. A second time: Write queries in something like phpMyAdmin to check your results!
  13. "appears saying the page has been accessed in error". The problem at least start in this code: // Add the message to the database: $r = mysqli_query($dbc, "INSERT INTO page_posts (user_id, page_id, message) VALUES ({$_SESSION['user_id']}, {$_GET['id']}, '$m')"); if (mysqli_num_rows($r) != 1) { // Problem! $page_title = 'Error!'; include ('./includes/header.html'); echo '<p class="error">This page has been accessed in error.</p>'; include ('./includes/footer.html'); exit(); } The query is obviously not what you wanted - thus mysqli_num_rows is not 1. (It's likely zero) Do some checks against PhpMyAdmin to check if the query is right when used manually. (Use values instead of get, session and variables.) Often, the errors can be small and hard to catch like "page_posts" should really be "page_post". Hope you figure it out.
  14. I had that too. It's actually very simple. // A normal variable containing a number $a-number = 10; // This is 10 because it's before we use the function echo $a-number; // Now we use our function (see bottom) on this variable add_ten($a-number); // This is now 20 because of the function below echo $a-number; // This is a function that adds ten to the value function add_ten($function-variable) { return $function-variable + 10; } It does not matter what variable you put into the "use" part of the function. It can be named anything. That is why it's great. You could have a variable called "$another-number" and add ten to that as well.
  15. It's because of the sorting before the echo statements. // NORMAL SORTING // Print the array as is: echo '<h3>Array As Is</h3><pre>' . print_r($students, 1) . '</pre>'; // Sort by name: uasort ($students, 'name_sort'); // Print the array now: echo '<h3>Array Sorted By Name</h3><pre>' . print_r($students, 1) . '</pre>'; // Sort by grade: uasort ($students, 'grade_sort'); // Print the array now: echo '<h3>Array Sorted By Grade</h3><pre>' . print_r($students, 1) . '</pre>';
  16. Or you can do it like we do at our site. One coloumn for excerpt and one for the whole thing in the DB
  17. http://www.php.net/manual/en/function.substr.php Sorry. Got to go to the pub. Uefa Champions League Final today.
  18. Mysqli have functions called mysqli_multi_query mysqli_more_results: http://php.net/manua...ore-results.php $query = "SELECT count(*) as count FROM posts"; $query .= "SELECT * FROM posts WHERE posts.status='publish' AND posts.level='".$access_level."' ORDER BY id LIMIT $pageNum, $totalRows"; More than that, I cannot help you really. I haven't played with these functions yet. The thought is to use the first query to store the number of rows in the database, and the second one to get results. Hope this help, with the thought process at least.
  19. I read both your links, but some addition information about what it is, and possible some matter to discuss, would be even better. That's all I'm saying.
  20. Thanks, bahaa. Just one thing. I don't mean to play moderator wannabe here, but as I manage a forum of my own, I recommend you to give some additional info. You should make this possible to discuss too.
  21. You should take a look at the CodeIgniter framework as well, Larry. I've had trouble just installing YII, so I've haven't got around to try it.
  22. You don't need mysql*_real_escape_string() with Prepared Statement. I absolutely see your point though // Set Mysqli or Mysqli $MySQLI == TRUE; if ($MySQLI == true) { // do Prepared statements } else { self::sanitize_values($input); // do things with $value } private function sanitize_values($value) { // Only remove if magic quotes are enabled if ( get_magic_quotes_gpc() ) { $value = stripslashes($value); } // Then use mysql*_real_escape_string $value = mysql_real_escape_string($value); return $value; }
  23. When writing database structures, the normal way to do it is like this: table (primary_key, foreign key*, other_rows) It just makes it easier to read. I also like to name foreign keys with tablename_id. Adding fk after the name id_fk is also used to see that it's a foreign key.
×
×
  • Create New...