Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by doddsey_65

  1. When a user clicks on a topic they are transfered to its post, which is retrieved by the name of the topic as given by the url value. up to now i have just used urlencode. But its trickier when a user adds slashes and dots into the mix. for example the title of the post is testing/testing. The url will go to www.asimpleforum.co.uk/t/testing/testing. How would i get around this since url encode doesnt do the job? I could replace slashes and dots with their own unique symbol but that produces the problem when someone uses one of those symbols that i use to replace in their topic title. I know one site in particular that replaces all dots and slashes with a hyphen (-), but how would you know what to turn the hyphen into when you query the database for that topic? Anyone have any ideas?

  2. Thanks for the reply. The parse error in the profile walls has been fixed with the new template system. The user center has been removed, though you can not change your timezones currently. Ive also fixed the error in the like system so hopefully everything should work now.

  3. The following union query is supposed to return the total number of alerts and the total number of messages, however a dump of the returned array shows only the alerts(num_alerts).

     

    $sql = "SELECT COUNT(a.a_aid) as num_alerts 
                        FROM ".Asf_Db::$prefix."alerts a
                        UNION
                        SELECT COUNT(m.m_mid) as num_messages
                        FROM ".Asf_Db::$prefix."messages m";
                        
                $sth = Asf_Core::$db->prepare($sql);
                $sth->execute() or die(Asf_Core::$db->error($sth, $sql));
                
                $results = $sth->fetch(PDO::FETCH_ASSOC);
                
                dump($results);
    

     

    anyone see where im going wrong?

     

  4. your 404 error is probably due to this:

     

    Header("Location: $HTTP_REFERER");
    

     

    $HTTP_REFERER doesnt exist in your script. Did you perhaps mean

     

    header("Location: ".$_SERVER['HTTP_REFERER']);
    

     

    You need to place the jquery code within your HTML. Heres a quick example. You will need to include the jQuery script, either download it from  their website or use googles CDN.

     

    <script type="text/javascript">
    $(document).ready(function(){
         $('form').submit(function(e){ // the below code will fire when the form is submitted
              e.preventDefault(); // don't send the form via HTTP method
    
               $.post('.shout.php', 
               {
                      name       :   $('input[name="name"]').val(),
                      url            :   $('input[name="url"]').val(),
                      email        :   $('input[name="email"]').val(),
                      message  :   $('input[name="message"]').val(),
               }, function(data) // data is what will be returned from shout.php
               {
                      alert(data); // do something with the data
                }
    });
    </script>
    

     

    Then in shout.php instead of using header() to redirect them simply echo something to be sent back to the client script

     

    echo 'Form submitted';
    

     

    You will then get an alert saying Form submitted.

     

  5. perhaps you should try and start the "quest" first and then come back with some code to show us. no one is going to write code for you, But i may do it if you pay me $50.

     

    You can write post content to a file using fopen() and fwrite().

     

    You will need to look into jquery's $.post() function in order for your code to post without a refresh.

     

  6. Not many people will disable javascript. And alot of the major websites use no fallbacks at all for the lack of javascript. Look at facebook, twitter and youtube. Most of their functions are done with javascript, but they don't work at all if javascript is disabled. Saying that though, the search feature is the core component of your website, so there should be a fallback. If someone does visit with no javascript then theres no point in staying on your site. I only provide no fallbacks on extended functions that dont really impact the functionality of the site.

  7. Im using preg_replace in my template and hook system but have come across a problem.

     

    content within a loop is defined in the html as <loop_name-loop_key>

     

    so it replaces this with content in the loop which works fine.

     

    But adding <loop_name-loop_key> to another custom tag breaks the script.

     

    <asf: hook="post_message" params="<loop_name-loop_key>"> doesnt work because the preg_replace has already replaced <loop_name-loop_key> with its php values.

     

    I need to replace <loop_name-loop_key> only if it isnt within any other tags like the hook tag. Heres my preg_replaces

     

    $content = preg_replace('|\<'.$key.'\-'.$l_key.'\>|i', "<?php echo \$this->tpl_data['$key']['$l_key'][\$i]; ?>", $content);
    
    $content = preg_replace('|^\<asf: hook="([a-zA-Z0-9_-]+)" params="\<'.$key.'\-'.$l_key.'\>"\>(.*?)<\/asf: hook\>|sie', "\$this->replace_hook('\\1', '\\3', array(\$this->tpl_data['$key']['$l_key'][$i]));", $content);
    

     

    as you can see since the loop is being replaced before the hook the hook statement becomes invalid. How do i make sure the loop in only replaced if it's not in any other tags?

     

    I tried using ^ and $ to define beginning and end but it doesn't work, probably due to the indentation of the html.

     

     

  8. For my friend system usernames are stored in a table (f_username) along with the username of the friend (f_friend_username).

     

    Im trying to display the friends of a user on their profile but the users username can be in either the f_username column or the f_friend_username column.

     

    So i have this query but it returns the same result twice. Is there a better way around this? I thought about a conditional ON statement but don't know if it's possible.

     

    $sql = "SELECT f.*, u.u_avatar
                    FROM ".Asf_Db::$prefix."friends f
                    JOIN ".Asf_Db::$prefix."users u
                    ON (
                        f.f_username = u.u_username
                        OR
                        f.f_friend_username = u.u_username
                    )
                    WHERE (
                        f_username = ?
                        OR 
                        f_friend_username = ?
                    )
                    AND f_confirmed = ?";
                    
            $sth = Asf_Core::$db->prepare($sql);
            $sth->execute(array(
                $username,
                $username,
                1
                )
            ) or die(Asf_Core::$db->error($sth, $sql));
    

     

  9. use the [ php \] and [/ php \] tags without the ending backslashes.

     

    For your query just use !empty

     

    WHILE($rows = mysql_fetch_array($query)):
               $nickname = (!empty($rows['nickname'])) ? $rows['nickname'] : $rows['username']; // tells it to display username if nickname is empty
               echo $nickname;
            endwhile;
    

     

  10. Heres my crits:

     

    when the page first loads, it all seems a bit jumpy.

    The logo is hard to see againt the black

    no vaild doctype or encoding has been specified

    your notice div is included outside the body tags

    <hr> is not valid XHTML

    align="center" is not valid XHTML

    the message for no words fades out too quickly, so you cannot click add word to dictionary

     

×
×
  • 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.