Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    FlyLo11
    @FlyLo11

    @Norris1z the trick is using the extract function:
    definition:

    class View {
    
        private $templatePath;
    
        public function __construct($templatePath) {
            $this->templatePath = $templatePath;
        }
    
        public function render($template, $vars = []) {
            extract($vars);
            ob_start();
            require $this->templatePath . '/' . $template . '.php';
    
            return ob_get_clean();
        }
    }

    usage:

    $view = new View(__DIR__ . '/templates');
    $vars = [
        'name' => 'Alex',
        'location' => 'Paris',
    ];
    echo $view->render('hello', $vars);

    templates/hello.php:

    <div>
        Hello <?= $name ?>!<br>
        You are in <?= $location ?>.
    </div>
    Norris Oduro
    @Norris1z
    @FlyLo11 thanks .
    philly-vanilly
    @philly-vanilly
    is there a general reddit webdev room here on gitter
    Unknown
    @Unknownhezipaz

    $User_FName = $_POST['U_fname'];
    I want to know if the explanation below for the code above is right and if I can add to it

    //superglobal variable captures the value passed by form and store in local variable it is created when you use the post method in form to get the value that is entered in the form called u_fname.

    Unknown
    @Unknownhezipaz
    $SQL5="UPDATE orders SET orderTotal=".$total."
    WHERE orderNo=".$latestorderNo;// this updates the total value of orderTotal column in order table
    where the order No matches the order No of the order of the current user.
    Rami
    @RNwebdk
    @majedmahmood27 Do you have the code somewhere on github ?
    also, I'm trying to understand the problem, but i dont understand what your trying to do
    so maybe it's easier to see if i have the code
    Unknown
    @Unknownhezipaz
    @RNwebdk nope but how can I upload it I just need explanation of the code.It works
    Rami
    @RNwebdk
    Do you have a github account ?
    Unknown
    @Unknownhezipaz
    @RNwebdk yep
    Rami
    @RNwebdk
    okay, lets take it in private
    Roman Tsiupa
    @dracony
    hey guys)
    Jaider
    @jaider_jannis_twitter
    Hi guys
    need some help
    All info send to the template.html, but the info of telephone doesn't send why not what is my fault
    Unknown
    @Unknownhezipaz

    @majedmahmood27
    $time = date("Y-m-d H:i:s");//local varible that stores the date using the php function that format the date.
    is this rigth explanation
    right*
    // insert statment to put into orders the values id that is in the session ,time dynamically retrieved from local varibale and subtotal from local variable

    $userSQL =
    "insert into
    orders (userID, orderDateTime, orderTotal)
    values (".$_SESSION['c_userID'].",'".$time."','".$subTotal."')";//userID that is in the session
    $exeuserSQL=mysql_query($userSQL);

    if(mysql_errno($conn) == 0)
    {
    //return the greatest order number... Meaning the largest number in the column and rename the column to max no
    $orderCheck = "SELECT max(orderNo) as 'maxno' FROM orders
    WHERE userID=".$_SESSION['c_userID'];
    $exeorderCheck = mysql_query($orderCheck) or die(mysql_error());
    $orderArray = mysql_fetch_array($exeorderCheck);
    $latestorderNo=$orderArray['maxno'];// stores max number of order for this particular user and store in local variable.
    echo "<p>Order has been placed successfuly";
    echo "<b><p>ORDER NO: ".$latestorderNo."</b>";// dynamically retrieve the value from the local variable latestorderNo.
    $SQL5="UPDATE orders SET orderTotal=".$total."
    WHERE orderNo=".$latestorderNo; this is update sql statement that updates the orderTotal database column using the total local variable wherethe orderNo matches the orderNo of the current user who has just placed an order
    $subTotal=$reququantity * $results3['prodPrice']; this is quantity retrieved from the for loop that times the array of records $result3 that references the prodPrice database column
    echo "<label for='First_name' >First Name: </label>"; what does label for do
    echo "<input type='text' name='U_fname' value=''><br>";//U_fname is the name of the textfield for First Name and is this right

    Open web market
    @openwebmarket_twitter
    i would like some one to show me how to run this code (flif.exe -e input.png output.flif)
    <?php
    shell_exec(“flif.exe -e input.png output.flif”);
    ?>
    this code (flif.exe -e input.png output.flif) is giving me this error Parse error: syntax error, unexpected 'input' (T_STRING) in C:\
    downhiller
    @downhiller
    I create multiple instances of a class in my code. Inside one of the class methods I have static $x = 0; $x++; When I call that method repeatedly, $x correctly increments. But when I call it from a different instance of the class it carries on from the same number, rather than starting from 0
    how can I get the static behaviour I want across multiple calls in the same instance, whilst starting from 0 for each separate instance?

    Essentially, how can I fix this?

    class MyClass() {
        // ....
    
        public function inc() {
            static $x = 0;
            $x++;
            return $x;
        }
    }
    
    $a = new MyClass;
    echo $a->inc();  //1, correct
    echo $a->inc();  //2, correct
    echo $a->inc();  //3, correct
    
    $b = new MyClass;
    echo $b->inc();  //4, incorrect, should be 1
    echo $b->inc();  //5, incorrect, should be 2
    echo $b->inc();  //6, incorrect, should be 3

    thank you!

    downhiller
    @downhiller
    please ignore me, I realise how fuckbastardingly retarded I've been. That's what I get for trying to do 17 things at once after a month away from coding!
    Matthew J. Sahagian
    @mattsah
    well this place is dead
    Richard Hagen
    @Richard87
    @mattsah haha, it appears you are correct :/
    Rami
    @RNwebdk
    It use to be very active though :(
    Richard Hagen
    @Richard87
    yup :/ It's to bad... maybe people still come around ;)
    btw, do you have any experience with docker / deployment routines?
    Rami
    @RNwebdk
    No sorry, i want to look into docker myself.
    Richard Hagen
    @Richard87
    :) thanks tho
    Rami
    @RNwebdk
    @Richard87 join this slack channel, i'm sure you'll find someone that can help there
    Richard Hagen
    @Richard87
    thanks :D
    downhiller
    @downhiller
    Well it's been a lot of work, but I've finally converted my whole legacy codebase over to parameterised PDO queries. Easy for a lot of them (but there were a LOT of them), a bit more annoying for the queries that get built up in conditional logic. Feels good.
    FlyLo11
    @FlyLo11
    now it's time to replace that with an ORM :P
    downhiller
    @downhiller
    You shut your mot
    You shut your mouth :)
    FlyLo11
    @FlyLo11
    :D
    you could try doctrine/dbal, it should be a drop-in replacement for PDO, and comes with some query building support
    downhiller
    @downhiller
    I've always assumed that such a system would be too limiting - SQL is a very diverse language and while a coded query builder could account for 99% of my queries' needs I feel there would always be things I'd end up having to hand code?
    Rami
    @RNwebdk
    guys, i'm on a discord that has a little more activity then here, let me know if you would like a invite
    Ricardo Reis
    @rickomax
    Hey
    Anyone had issues with "readfile" and binary files?
    Actually, when using "readfile" to download a file on PHP, newline (13) characters get stripped
    image.png
    Nicolaj Kirkgaard Nielsen
    @NicolajKN
    Is there a way to receive a GET response from a server and echo it directly, including headers etc. I have an API endpoint i Wordpress that needs to request an image from another API with a token. The WP endpoint should just return the image exactly like the API response from the other API.