Jump to content

Drongo_III

Members
  • Posts

    579
  • Joined

  • Last visited

Posts posted by Drongo_III

  1. Sorry didn't spot that. I really should read posts properly before posting!

     

    I just ran your code without including the header or footer and with a session usname set at the top. It worked fine.

     

    Is there more php in your header or footer? And are you sure the username sessions is getting set?

     

     

     

     

      its this <?php

    }

    else

    echo "<font color='red'><center><h1>You must be logged in to view this page.</h1></center></font>";

  2. Hi mate

     

    For a start this line looks dodgy. You have an opening curly bracket but no closing bracket

     

    
    <?php if ($username){?>
    

     

    I keep geting this i dont whats worong with it

     

     

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING  line 1

     

    <?php
    session_start();
    $username = $_SESSION['username'];
    ?>
    <?php
    require "header.php";
    ?>
    <?php if ($username){?>
    
    <?php
    
    echo "<br/><br/>"."Welcome <b>$username</b>, <a href='logout.php'>Logout</a href>"."<br /><br />";
    
    ?>
    <?php
    
    echo "<center><h2>Hey $username! What do you want to do?</h2></center>";
    
    ?>
    
    <div id="ahome">
    
    <table>
    <form action="createnews" method="post">
    <tr>
    <td><td>
    <td><td>
    </tr>
    <tr>
    <td>Title of Article<td>
    <td><input type="text" size="45" name="newstitle"/><td>
    </tr>
    <tr>
    <td>Author of Article<td>
    <td><input type="text" size="40" name="by"/><td>
    </tr>
    <tr>
    <td>Body of Article<td>
    <td><textarea cols="45" rows="25" name="newsbody"></textarea><td>
    </tr>
    <tr>
    <td><td>
    <td><input type="submit" name="submitbtn" value="Add News"/><td>
    </tr>
    </form></table>
    
    </div>
    
    <div id="rhome">
    
    
    New Admin Stuff Coming Soon....<br></br>
    
    
    <a href="#">Create a New Page</a><br></br>
    <a href="#">Edit a Review</a>
    
    </div>
    
    
    
    <?php
    }
    else
    echo "<font color='red'><center><h1>You must be logged in to view this page.</h1></center></font>";
    
    ?>
    <?php
    require "footer.php";
    ?>

  3. Hi Mate

     

    It looks amazing.

     

    One thing i would point out is the "pages" drop down. What happens when the user has 10 top level pages? I can see that getting big!

     

    Also not big on the scrolling text on the dashboard landing page. It's jittery and unclear.

     

    Otherwise i really like it!

     

     

  4. Well that function will count the occurances of each array item.

     

    So if you have an array of the basket items you can do a count on the array items. Then if they occur more than once you can set the count as the quantity.

     

    Sorry i didn't read through your code that closely but it seemed like a possible solution... :)

     

     

    not sure i entirely understand? sorry!

  5. Not entirely sure what your array looks like but using

     

    $dupes = array_count_values($array);
    

     

    This counts all the occurances of each value and returns an array. The returned array has the original value as the key and the number of occurances as the value.

     

    So with a bit of logic you should be able to use those values in your display :)

     

    Hope that helps!

  6. Hi

     

    How far along are you with this? Firstly does that query return anything?

     

    Plus in your function you are returning the value but that won't make it appear unless you echo your function or print_r your array.

     

     

     

    I have the following code but I cannot get it to print the results of the array into my web page.  Help would be so appreciated!!

     

    $sql = "SELECT RegName, SireID, DamID FROM pedigrees WHERE ID=";
    
    $DoggieIDQ = $sql . $values["ID"];
    $DoggieIDR = db_query($DoggieIDQ,$conn);
    
    
    $DoggieID = $_GET['ID'];
    $Depth = 1;
    $DepthLimit=8;
    
    function getParents($DoggieID, $Depth, $DepthLimit)
    
    {
        $Sire = getSire($DoggieID);
        $Dam = getDAM($DoggieID);
        $Depth++;
        if ($Depth == $DepthLimit) {
            return array($Sire, $Dam);
        } else {
            # Now get grandparents too
            $SireParents = getParents($Sire, $Depth, $DepthLimit);
            $DamParents = getParents($Dam, $Depth, $DepthLimit);
            return array($Sire, $Dam, $SireParents, $DamParents);
        }
    }
    
    

  7. Last answer was probably best but you can break a string at a particular delimter using explode() function

     

    
    $str = "this/is/my/str";
    
    $myarray = explode('/', $str);
    
    print_r($myarray);
    
    

     

    That will produce an array with each value being whatever is between the slashes.

     

     

    Ok so I'm coding up a file tree for a script and I've got the system setup so that when a user clicks on a folder it adds that folder to the path. The path is stored in a variable, but I'd like to allow the user to be able to go down multiple directories at once. To do this I'm going to seperate each folder name in the path and link to it so as an example:

     

    $path = './home/public_html/folder1/folder2';

     

    how can I separate each of those so I can make a link to that folder so that:

     

    /home goes to $path = './home/';

    /public_html goes to $path = './home/public_html';

    etc...

    ---

    Basically just seperate the slashes into an array and seperate each of them off based on how far along it is but I don't know how to do that...

  8. Are you just trying to print the entire array? You can't print or echo an array - only individual array values.

     

    To get the whole array use

     

    
    print_r($Name_of_Array);
    
    

     

     

    atm i have this in a function:

     

    $returnInfo = array();
    
    $returnInfo["totalWords"] = $totalWords;
    $returnInfo["uniqueWords"] = count($uniqueWords);
    $returnInfo["positiveWords"] = $positiveWords;
    $returnInfo["negativeWords"] = $negativeWords;
    $returnInfo["rating"] = $mappedrating;
    
    return $returnInfo;	
    

     

    If i recursive print it it says Array instand of my expected values.

     

    p.s., i have found examples where the array get's created in 1 line with all there values but i prefer not to do that since it will be a very long line.

  9. Yeah it's a nice lookin' site in firefox :)

     

    I would probably try fix the main errors too cos that might repair a multitude of issues and with luck will spring everythnig back into life.

     

     

     

     

    With a little work it may work

     

    You have a lot of minor errors according to http://validator.w3.org/.

     

    Put your url in w3 and then look at your source html and find the problem in your php files.

     

    There is two mentions of open comment tags with no closing tags. There are escaping slashes in your JavaScript, meaning you used single quotes or something and then escaped the double quotes. Many are repeated errors, something wrong with your code not smarties .

     

    Get fire foxes fire bug and it will also help you find your problems.

     

    PS it will look d****n fine when your through

  10. I think you'd be quicker to start over! That's a mess.

     

     

    Hello all;

    My site is at: http://www.designtoprint.com

     

    The problem is that it looks great in everything but Internet Explorer.  In I.E., it's utterly broken.  I think this has a lot to do with the fact that the former developer who worked on it did everything in Smarty.  I'm wondering if there's a way to automate the process of recombining all the Smarty pages back into normal .php files.  Or barring that, if any of you smarter-than-me people know off the top of your heads why my site is breaking in I.E., but nothing else.  :)

    Thanks!

    Kyle

     

     

     

  11. Hi Guys

     

    I have been banging my head trying to get this to work.

     

    I am just trying to iframe content from my Amazon S3 bucket into a facebook page via the facebook app. When i do it off my server it works fine. When i do it via the bucket i get an "method not allowed" error.

     

    I read around a lot and a few posts say it's because facebook uses the GET method whereas Amazon S3 uses the POST method to transfer data.

     

    The thing is i chose amazon because i could acess content through both http and https but i don't know how to get facebook to play ball with amazon S3 and i don't really want to spend money on a ssl certificate for my server for such a simple thing.

     

    Does anyone know of a work around ?

     

    Any yes, i feel it's important to serve both http and https as a lot of people use the secure privacy setting and won't get to see the content if it's not https.

     

     

    What i want to achieve is so simple and yet again the facebook makes it impossibly hard!  >:( HATE FACEBOOK!

  12. Thank Req that all makes a LOT more sense now :)

     

    Use the same records on yours and make the switch. Everybody using the old nameservers will get the same information as the people using the new nameservers. No disruption because there's overlap.

    Problems happen when there's a gap, like taking down the old ones before everybody's using the new ones, or when changing mail servers. I'd wait at least a week between those kinds of changes.

  13. Thanks Req!

     

    That makes a lot more sense to me now.  :)

     

    So if i wanted to point a client's domain to my server using my nameservers, but they already have mx records setup and working. What's the best way to ensure there's no disruption to their emails?

     

    Should i simply setup the zone file on my server (mx records and all) before i point the name servers? Or is there no way to really avoid disruption?

     

     

     

     

    123-reg is letting you edit their DNS information. Not yours. But if the nameservers actually do point to your stuff and not theirs, editing their information will do nothing... unless you switch the nameservers back to theirs.

     

    GoDaddy simply doesn't let you edit the information that isn't being used. Perhaps as a disambiguation: you can't be confused why the settings aren't working if they don't let you change them in the first place.

  14. Hi guys

     

    I wonder if someone can help me understand something.  I know a little about nameserves and dns but only enough to get by.

     

    Here's the odd thing...

     

    When I purchase a domain on 123-reg.co.uk and point it at my server using my nameservers I can still access the dns records (on the 123 reg control panel). I have to point the A record at 123 reg but besides that i can still set mx records etc from 123 reg. All good.

     

    However, if i setup a domain on go daddy and point it using my name servers (at my server) it ceases to allow me to access any of the dns info. So i can't set the mx record etc. in go daddy and instead i have to edit a zone file on my own server to set these records.

     

    So my question is why would the two services act so differently and is this simply down to the way they setup domains?

     

    I would really like to understand this :(

  15. You would probably need to start a session to track the user if you wanted to do that. Then have some logic to determine the page visited before the form page. At least that would be my first guess at how to do it.

     

    You'd essentially just keep overwriting the same session variable for every page unless the user is on the form page where it would pull the page variable instead of overwriting it- which would at that point be set to the last page visited.

     

    Although someone might suggest a better way of doing it.

     

     

     

    Thanks @SergeiSS,

     

    It works perfectly!

     

    Is the also a way to redirect to an even lower level i.e to the page before the form page?

     

    Thanks

  16.  

    You could change header location on the page that processes your form data.

     

    So once it's done all of the processing (and assuming it doesn't output anything to the page) do:

     

    
    <?php 
    
    header('Location: http//www.YourFormPageLink.com');
    
    ?>
    
    

     

    And that'll redirect them anywhere you want.

     

    Alternatively if you don't know precisely what page they originated from then you could grab the url of the form page and set it as part a session variable or post it with the form. Then use that data in your header location to send them back to that link.

     

    Hi guys,

     

    Is it possible to make a page automatically redirect to the previous page a user was in once they submit a form?

     

    Thanks

  17. If your images originate from an array how about:

     

    <?php 
    
    
    
    
    //Do you array count to get number of values and set this to count
    
    $img= array();  //images array
    $img[] = "image1";
    $img[] = "image2";
    $img[] = "image3";
    $img[] = "image4";
    $img[] = "image5";
    $img[] = "image6";
    $img[] = "image7";
    $img[] = "image8";
    $img[] = "image9";
    $img[] = "image10";
    $img[] = "image11";
    $img[] = "image12";
    
    
    $count= count($img);
    echo "$count";
    
    for ($i=0; $i<$count; $i++){
    
    if ( $i==0){
    echo "<div>";
    }
    
    if ($i % 5 == 0 && !$i == 0){
    
    echo "</div> <div>";
    }
    
    echo $img[$i];
    
    
    
    
    
    }
    
    echo "</div>";
    
    ?>

  18. Well you could change it so it matches the class as a literal and then it would only target that div.

     

    Didn't know pattern_order was the default. I've always used it just for the sake of it. I've only used regular expressions for pretty basic stuff to be honest.

     

    Thanks for the tip :)

     

     

    @Drongo_III

     

    There's no need to pass the PREG_PATTERN_ORDER flag, it's the default. Though your pattern would match all DIVs with just a class attribute, so it's not really a practical solution.

     

    @hamza

     

    I think your problem is using ^ and $ at the start/end of the pattern. Together these require that the pattern is the *only* contents of the string. You can omit either or both to remove that restriction from one or both sides of the pattern.

  19. You could use:

     

    
    $string = 'The older way of doing this, with gconftool-2 doesn’t seem to work anymore in GNOME 3 – used to be something like:<br /><br />However, there is still possible to change the background image, by using the gsettings tool instead. You will need the libglib2.0-bin package, which is probably already installed on your system. To change the background, use a command like the following:';
    
    
    $patterns = array();
    $patterns[0] = '|<br /><br />|';
    
    $replacements = array();
    $replacements[2] = '';
    
    echo preg_replace($patterns, $replacements, $string);
    
    
    

     

    That will remove any insteance of your double line break. However, if you're going to use it a bit more widely then you might want to make the regular expression a bit cleverer in that it will currently match precisely the way

     

    <br /><br />

    is written - spaces and all.

     

    But should set you on the right path :)

     

     

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