Jump to content

Daen

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Daen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I've talked to a friend and he explained the LIMIT part of the statement a little more-- I had misunderstood it.  Both of your ideas will work then.  Thanks for the help, I appreciate it!
  2. Well, that's what I'm doing for the first page, and it works just great.  The problem comes up when I need to try and calculate what the $start is going to be.  I can do a next page link just fine, but when trying to calculate a previous it causes problems.  I also want to be able to have a string of links that shows something like "start prev 1 2 3 4 next end".  Since the numbers aren't all consecutive, it's not as simple as most of the examples I've found. (Oh, and I forgot to mention, I'm running MySQL 4.0.14, so I can't use subqueries-- which would have solved my problem as well... *sigh*) Any ideas?
  3. Hey guys,  I'm the new web master for a forum site, and have had a new feature requested:  Some of the forum members want to be able to see all of a member's posts, ordered by when posted.  Here's the issue:  Some people as you can imagine have several hundred posts (or more), and that's just not doable to put them on one page.  There is one table that holds all the members' posts, has a thread id and a message id, as well as the poster's user id.  I can select out just the posts by a user just fine, but I need a way to be able to break them up into pages.  The problem comes up because you could have other users post in between another's two posts, and it throws the counting out of whack.  Let me see if I can give an example to better illustrate: User A posts something on thread 1.  It's inserted into the messages table with message id 1 User B then posts something on thread 1, it's inserted into the messages table with id 2 User A posts something again on thread 1, inserted into messages table with id 3 User C posts something on thread 2, inserted into messages table with id 4 User B posts something on thread 2, inserted into messages table with id 5 User A posts something on thread 3, inserted into messages table with id 6. So, I need to pull out all of user A's posts and be able to paginate them.  Now say that users A, B, and C have roughly 500 posts each, with the message id numbers all interspersed like that.  :-\ Unfortunately, all the tutorials I've been able to find out on the 'net (including the ones here at phpfreaks) deal with the concept that all the stuff you want to paginate is in a nice little order that's easy to count.  You just get 1-10, say, then page number * 10 to that + 10, and so on.  Unless I'm missing something, I don't see how this could work for my situation. Has anyone else run into a similar situation and/or have any ideas?
  4. Well, curses: it looks like my host is running MySQL 4.0.24.  I had thought it was 4.1, but I guess the lack of subquery support would explain some of the errors I've been getting in other queries I've tried to run.  I'll have to see if there's anyway I can get them to upgrade the version. Yeah, with regard to using the PostID to sort them, I was talking about just one inserted first having a lower number than one inserted later-- not necessarily 1,2,3,4.  I really appreciate the help, though.  I managed to get the last query you posted to work as expected using a UNION. Thanks again!
  5. [code]SELECT person.id AS personID FROM person INNER JOIN rating ON person.id=rating.person_id WHERE (rating.movie_id=45 OR rating.movie_id=56) AND rating.value=5[/code] That will return multiple rows for one person, though... Off the top of my head I'm not quite sure how to combine those into just one row.  You might try changint the above WHERE clause to something like [code] EXISTS (SELECT COUNT(rating.person_id) WHERE (rating.movie_id=45 OR rating.movie_id=56) AND rating.value=5)[/code] Something like that ought to do it, I think.
  6. I'm still getting an error, but I don't understand why.  Running it through phpMyAdmin gives: [code]#1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT     PostID     FROM     Posts     WHERE     PostO [/code] It seems like it should work to me... I added a couple of parenthesis after the inner 'SELECT MAX/MIN' statements in order to maintain the correct number of them, but I would think that would prevent problems rather than cause them... Any ideas on this error?  I still even get an error (same one as above) if I remove all the surrounding SQL and just run [code]SELECT PostID FROM Posts WHERE PostOrder=(SELECT MIN(PostOrder) FROM MBPosts WHERE ThreadID=$threadID)[/code] As to adding an index on PostOrder, it's not unique.  There are multiple threads in the table and each one's posts has PostOrder going from 1 to however many posts there are in the thread.  Is there a way to add an index to a non-unique field?
  7. That didn't work.  PostOrder and PostID are fields in the table Posts.  [pre] --------------------------------------------------------------- |                          Posts                              | --------------------------------------------------------------- | PostID    | PostOrder    | ThreadID      | OtherStuff...    | --------------------------------------------------------------- |          |              |              |                  | |          |              |              |                  | |          |              |              |                  | --------------------------------------------------------------- [/pre] I suppose I could select the MIN/MAX of PostID because the PostID field is just an auto-increment as long as I have the WHERE ThreadID=$threadID, but I'd rather not because I'm not sure if that's guaranteed to be in the right order, whereas the PostOrder field does guarantee the order.
  8. If you don't mind having the page reload every time the user submits something or picks a new value, then you can do it with php and a little bit of javascript.  You just need to have a few hidden form fields on your page, and when the user submits one button, the javascript sets the form field value to some flag key value, then submits the form with page.submit().  Your php code looks for the flag value, then runs the query you want, and spits out the result page with the new results of the query. If you do mind the page reloading, then you'll have to go with AJAX, I think.
  9. [url=http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html]http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html[/url] This page says that 'Character' is a reserved word.  That might be affecting it, since that's your table name.
  10. Hey guys, not really familiar with complex SQL queries, so I thought I'd ask and see if you could give me a little help on this one.  I have a simple message board and I want to be able to select the post IDs of the first and last posts in the thread.  I have a column called PostOrder which is essentially a column that increments as posts are added to a thread, that way the message board can show them in the right order.  They're identified by the MIN(PostOrder) as the first post in the thread, and MAX(PostOrder) as the last in the thread.  So, essentially I want to be able to get out the PostID of the first and last posts in the thread on one row of a result set.  But, I'm not sure how to go about doing it.  I know it's possible, but not sure how. Essentially I want something like this: SELECT PostID FROM Posts WHERE PostOrder=MIN(PostOrder) AND ThreadID=$threadID and SELECT PostID FROM Posts WHERE PostOrder=MAX(PostOrder) AND ThreadID=$threadID in the same query so they return on the same row.  Unfortunately, I can't even get that syntax to work because I get an invalid use of group function error. Does anyone know how I could get that information out?  I appreciate any help you could give.
  11. When I try the first one I get a warning about no ending delimiter found, and I still get the slashes.  I guess if you meant for me to try the preg_replace() instead of mysql_real_escape_string(), then that might work, but I'd rather not have to do that if possible... Especially since I've never had a problem with stripslashes() before like this.  It just doesn't make any sense. I even tried assigning a separate holder variable for the commentText before I call mysql_real_escape_string(), and somehow the slashes even get in when I use the holder variable.  It's really bizarre. I finally got it to work by using [code]$commentText = str_replace("\\", "", $commentText);[/code]
  12. Hi, Got a comments form that I'm trying to get to work on my website.  People can post their writing and have others comment on it.  So, I want the comments form to send an email to the author of the story being commented on.  But, stripslashes isn't working as I expect it to. [code] function check_form($necessaryVars) {   // ... other form processing above   $commentText = mysql_real_escape_string(nl2br($commentText));   $subject = mysql_real_escape_string($subject)   // insert $commentText into the database   sendNotice($commentText, $subject);   // end the form checking function } function sendNotice($commentText, $subject) {   $commentText = stripslashes(str_replace("<br />", "", $commentText));   $subject = stripslashes($subject);   echo $commentText;   echo $subject;   // assume necessary variables here are taken care of, except $commentText   mail($authorEmail, $subject, $commentText, $from); } [/code] $commentText is taken from a textarea on an html form.  If I input something like "Here's a comment." it comes out as "Here\'s a comment." even after the explicit call to stripslashes().  The really weird thing is it's working just fine on the call to clean up $subject. Does anyone have any ideas as to why this might be happening?  I've got similar things happening on other pages of my site-- calls to [code]stripslashes(str_replace("<br />", "", $someText))[/code] -- and they all seem to work just great. I appreciate the help.
  13. Well, this might not be the most appropriate place to ask about an Xampp version of Apache, but since their forums are all in german, and I can't read german, I thought I'd see if anyone would know how to solve the problem here. Ok, I'm trying to put an alias in my httpd.conf file in order to access a mapped network drive. I have Apache set to logon in service mode with a username that has access to said network drive. Here's the relevant part of the .conf file: [code]Alias /mediaFiles/ "X:/Evaluation & Measurement/English Certification Test/Student DATA/" <Directory "X:/Evaluation & Measurement/English Certification Test/Student DATA">     Options Indexes MultiViews     AllowOverride None     Order allow,deny     Allow from all </Directory>[/code] Now here's the weird part. When I start apache from the command line, it runs just fine, and I can even access the aliased directory. When I try to start it with the Xampp control panel, it starts, then dies right after. No errors logged in the error log, nothing. Just dies. Has anyone had a similar problem or have any ideas how to fix it? I guess I could run it through the command line if I have to, but I would really rather be able to run it through the control panel if possible. Thanks for any help you can give.
  14. I'm running XAMPP on my machine (localhost), and Oracle on another server: ApacheFriends XAMPP (basic package) version 1.5.2 + Apache 2.2.0 + PHP 5.1.2 + PHP 4.4.2-pl1 + PEAR Ok, here's my code: test.php: [code] <?php     include('include/connectORA.php');     echo "<html>\n<body>\n";          echo "Attempting to connect to Oracle database.<br>\n";          $conn1 = connectORA();          if(!$conn1)         echo "Error connecting to database.<br>\n";     else         echo "Successful!<br>\n";          echo "<br>Attempting to select data from database.<br>\n";          $table = "PERSON";          $sql = "SELECT * FROM ".$table;          $stmt = oci_parse($conn1, $sql);   // <-- has problem right here     oci_execute($stmt);          echo "Results: <br>\n";          $row = oci_fetch_assoc($stmt);          print_r($row);              echo "</body>\n</html>"; ?>[/code] connectORA.php [code]<?php     function connectORA()     {         $db = "MYNAME";         return ocilogon("mydb", "mypass", $db);     } ?>[/code] When I run it in Firefox, Apache gives me the following error "Apache HTTP Server has encountered a problem and needs to close." Then it tells me that the document has no data in it, and Apache keeps running afterward. Kinda strange it tells me it crashed, and then doesn't. If I comment out the lines after $sql = "..."; then it works just fine, and I even get a connection successful notice. If I uncomment oci_parse(), then it gives me the error again. Does anybody know what might be causing this? Am I maybe getting a bad connection, even though $conn1 isn't null? I appreciate any help.
  15. [!--quoteo(post=337173:date=Jan 17 2006, 12:20 AM:name=juicyapple)--][div class=\'quotetop\']QUOTE(juicyapple @ Jan 17 2006, 12:20 AM) 337173[/snapback][/div][div class=\'quotemain\'][!--quotec--] I have uncomment the line in c:\windows\php.ini extension=php_oci8.dll I was having the exact same problem, and this is what I did: Make a little page that just has <?php phpinfo() ?> in it and see what the result says. Look for where PHP thinks the php.ini file is (You could probably search for "php.ini"). Make sure that's the one you edited. No other php.ini files make a difference. I'm running XAMPP and it put the .ini in a different spot than I thought it would: Apache\bin\php.ini. After you modify the php.ini file, you have to restart Apache for the settings to take effect. That should probably clear up your problem. You shouldn't have to move the .dll files anywhere. Good luck!
×
×
  • 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.