Re: [PHP-DB] This won't work in MySQL 4.1.10
Peter Karlsson wrote: but it runs fine in 4.1.20. In .10 I get an error message about unknown column c. I built the sql with help from the comments from the MySQL website manual and have to admit that I don't fully understand it all ;). Is there a way to solve this without upgrading the server? SELECT DISTINCT O.id, O.header, O.state, O.prio, O.publication_date, O.user_id, MATCH (C.body) AGAINST ('mysearch') AS relevance FROM texts AS C JOIN jobs AS O ON C.job_id=O.id WHERE O.paper_id = 1 AND MATCH (c.body) AGAINST('+mysearch' IN BOOLEAN MODE) HAVING relevance 0.2 ORDER BY relevance DESC You have the cases mixed up (sql is case sensitive in different areas). You have FROM texts AS C then MATCH(c.body) AGAINST(...) Try changing the second match against to be C.body instead.. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] retaining form information when someone presses back
Christopher Blöcker wrote: Flint Million: This might not be relavent for this forum, so if not please direct me to the proper one; although I do like to keep my email list subscriptions down. I have a custom application in PHP in which a user fills out a form of information. When the user submits, I perform sanity checking on the user's submitted data and refuse to actually process/insert it if those checks fail. However, my users are complaining that when they press back to correct, all the data is gone from the form and they have to re-enter it all. I know many websites that can retain the form data when someone presses back; how is this done? Flint M ok, an input field might be something like input type='text' name='username' size='8' maxlegth='32' -- the submitted variable would be stored in $_POST[username] (or $_GET[username] depending on what method you use to submit it) Please no! *At least* use htmlentities or htmlspecialchars to stop xss attacks. If I put: scriptalert('x');/script as my username, and that alerts 'x', then I can steal cookies from your computer and other bits of info as well. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Can't figure out why getting query was empty error
pantichd wrote: Figured it out. The name of the table was Person instead of person...First letter was a capital P I didn't realize that the sql was case-sensitive. It is with table names, field names and table aliases. Stuff like SELECT, INSERT, UPDATE, WHERE isn't case sensitive (the sql keywords). Also - if you want help, please post the problem code *exactly*. You had three problems in the post that have nothing to do with this solution: mysql_select_db (table); (Not really a problem but I highly doubt your database is called table) mysql_query(INSERT INTO person (FirstName, LastName, Age) VALUES('Jack', 'Bauer', '67')); //Try to insert the record if (!mysql_query($sql,$con)) $sql is not defined anywhere - this would produce a query is empty error. and finally you were running the query twice. It's not a problem but it would be a hard-to-find-bug: // Close the connection mysql_query($sql,$con);mysql_close($con); If you post the exact code that's having the problem it makes it so much easier for everyone to help... -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL Performance Help
Tony Grimes wrote: I'm developing a course calendar for a client and I'm running into performance problems with the admin site. For example, when I try to include registration counts in the course list, the page really slows down for large course lists (50 or so): COURSEATTENDEES CAPACITYSEATS LEFT === == Course 1 5 10 5 Course 2 6 15 9 Course 3 4 10 6 I've been using one query to retrieve the course list and then one for each attendee count. Is there a more efficient way of doing this all in one query? I was thinking something like this (I'm not a SQL expert, so I don't know if this is even possible): SELECT course_name, capacity, count(query here) as attendee_count FROM events AS e LEFT OUTER JOIN event_attendees AS a ON e.event_id = a.event_id WHERE start_time BETWEEN point_a AND point_b Or should I just pull everything as a separate row like this and sort it all out programmatically: SELECT e.course_name, e.capacity, a.user_id FROM events AS e LEFT OUTER JOIN event_attendees AS a ON e.event_id = a.event_id WHERE start_time BETWEEN point_a AND point_b Or should I just try caching the data in PHP? Would an index help? Index your tables, make the database do the work. Much easier and less prone to bugs :) Check you have an index on: events(event_id) event_attendees(event_id) table(start_time) (whichever that table applies to - I assume it's events). Maybe try a multi-column index if this query gets run a lot: create index event_eventid_start_time on events(event_id, start_time); Use 'explain' to see which one is being used and possibly get rid of the other one. I have a guide about how to index databases here: http://www.designmagick.com/article/16/ (Yes it's a postgresql site but the same rules apply to mysql and other databases as well). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] 10 rows
Ron Piggott (PHP) wrote: I would normally just pass the offset through the get var. I understand what you are saying in concept ... but what would a sample command be like? a href=http://www.host.com/script.php?next=21;Next Link/a a href=http://www.host.com/script.php?previous=1;Previous Link/a You can either do it like that or just pass the page number across: a href=http://www.domain.com/script.php?page=1;Prev/a Viewing page 2 a href=http://www.domain.com/script.php?page=3;Next/a It's up to you.. Either way make sure you validate your data: ?php $number_of_records_per_page = 20; $page = 1; if (isset($_GET['page'])) { $page = (int)$_GET['page']; } if ($page 1) { $page = 1; } so people can't put in strings (xss or sql injection attacks) as the 'page' number - and so if it goes below 1 it gets reset to the first page. $start_record = ($page-1) * $number_of_records_per_page; I take 1 off so the first page is '1' not '0'. The query then comes out as: $query = select limit . $start_record . , . $number_of_records_per_page; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pdo_odbc and odbc
james tanhs wrote: Hi, I m running on : client: XP + Apache2.2+Php5.2 ( enabled pdo, pdo_odbc, Merant) server: oracle8i Are there anyone having the same problem ? Maybe ask the php-general list since you haven't got a reply here.. there are more people on that list and more chances that someone will have a suggestion about what's going on. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php