D
dnast

  • Feb 28, 2008
  • Joined Apr 24, 2004
  • When you first set up phpBB it asks which DB you want to use. Just put the files in separate folders and give them a different prefix for the table names and you're all set.

    As long as the other services allow you to choose a prefix for its table names, you shouldn't have any problems.

    • The table part looks fine (except that <form> should come before <table>). The problem is that we don't understand what you're trying to do with the second loop. 😉

      P.S. All of the rows in $result will have been fetched in the first loop. To fetch from $result again, you'll have to set the row pointer back to the first row (see [man]mysql_data_seek[/man]).

      mysql_data_seek($result,0);
      
      • What about a table like REFS (id, user_id, referral, active)? When the referee logs on for the first time set 'active' to "true" and "SELECT count(id) FROM refs WHERE user_id = $referrers_id AND active = 'true'" to see how many referred users have logged on so far.

        • Do the links have to be a simple URL or can you use tags in the profile? If you can use tags, just use the long URL to store the data and then send a location header to redirect them to the main page. They shouldn't see the real URL unless they look at the status bar (if there is one. I'm not sure where/how the profiles are shown) before clicking.

          • I'm not sure about the first one, but for the second you could use preg_replace on the query string to replace all multiple spaces with a single space before doing any other processing.

            $keyword = preg_replace('/[\s]+/' , ' ' , $keyword);
            • <form action="post">

              Action should be the URL the form is being submitted to and method is the one that should be set to "post".

              If you're posting to that same page then just give your submit button a name (ex. name="submit") and add an if clause to check if a form has been submitted.

              <?php
              if ($_POST['submit']) {
                // Update DB here
              }
              
              // Select from DB...
              ?>
              

              If you don't want to see the form again after submit, just put the SELECT code in an ELSE statement after if ($_POST['submit']).

              • Make sure your form tag looks like this

                <form enctype="multipart/form-data" action="__URL__" method="POST">

                Also try something like this to test whether the file was uploaded.

                if (!$_FILES['userpic']['error']) {

                Or just check when you use [man]move_uploaded_file()[/man]. If it doesn't work then you know the file wasn't uploaded. Check out the page Handling File Upoads in the PHP manual. They give a good explanation on how to handle file uploads.

                • You'll have to name each field.

                  SELECT * FROM `artists` WHERE `firstname` LIKE '%$search%' OR `lastname` LIKE '%$search%' ...
                  
                  • I've noticed some spamming going on in the Newbie Forum and automatically went to report the thread, but soon realized I didn't know where to click.

                    I honestly couldn't find the "Mark This Thread" link (unless it was just put there a couple of days ago), so I could be missing the reporting link.

                    If I'm not just overlooking the link, are there plans for bringing it back?

                    • ^ Wow, I've actually witnessed you making a mistake. 🆒

                      Weedpacket forgot the slash on tag 2 (which will have to be escaped, as well).

                      /\[TAG1=(.+?)\](.*?)\[\/TAG2\]/
                      
                      • Where is $resultsPerPage coming from? It sounds like it might be a query result instead of an integer.

                        • Ouch, it's so cryptic. 🙂

                          Would a LEFT JOIN for location data not work? If there's no location data for a specific item, the other information will still be included in the result leaving the location field blank.

                          • I'm not exactly sure if I understood what you're trying to do, but I'll give it a try. I assume that the select box allows you insert a specific item to a certain position. If so, I'd do something like this...

                            <?php
                            
                            //Shifting the other blocks around
                            if ($old_pos < $new_pos) {
                                $query = "UPDATE `leftnav` SET `pos` = (`pos` - 1)
                            WHERE `pos` <= $new_pos AND `pos` > $old_pos";
                            }
                            else {
                                $query = "UPDATE `leftnav` SET `pos` = (`pos` + 1)
                            WHERE `pos` >= $new_pos AND `pos` < $old_pos";
                            }
                            
                            $result = mysql_query($query);
                            
                            //Then put the selected block where it's supposed to go
                            $query2 = "UPDATE `leftnav` SET `pos` = $new_pos WHERE `id` = '$id'";
                            $result2 = mysql_query($query);
                            ?>
                            

                            Untested and I'm not exactly sure if that's what you were going for. Basically it sees if the new position for the item is higher or lower and changes the affected items accordingly. This shouldn't affect anything beyond the range between the old position and new. If this isn't what you were going for, hopefully you can use something from it.

                            If not, I'll try to help if you clarify more.

                            • If you really must do it this way, look into [man]implode[/man] and [man]explode[/man]. I strongly recommend reading up on database normalization, though.

                              Putting arrays into one field makes would-be simple things like finding out what stores eggs are bought from the most, for example, a lot more difficult and inefficient.

                              • Glad I could help. 🙂

                                Please mark this thread resolved (under Thread Tools at the top). 😉

                                • $sql = "SELECT DISTINCT alpha FROM dictionary ORDER BY alpha";
                                  
                                  • $row is only holding the first row of the result. You'll have to loop through the rows to get all of the values in the rows.

                                    An easier way to achieve what you're trying to do is use count() in your query.

                                    SELECT `fieldname`,count(`fieldname`) FROM `table` GROUP BY `fieldname`
                                    
                                    • The first argument in explode() has to be a character. You can't use NULL there. You'll probably just have to set $App "manually".

                                      $App = array($X,$A,$B);
                                      
                                      • I don't see why it's giving an error for that (maybe an older version of PHP?), but you might as well do that line like the rest of the code. Shouldn't get an error that way.

                                        $sql = "UPDATE `".$tbl_prefix."shrimp_stores` SET ";