Jump to content

glassfish

Members
  • Posts

    119
  • Joined

  • Last visited

Posts posted by glassfish

  1. I've dealt with all this on a video site and also my search engine.

    Thanks for your post. The post helps! I would be looking to know if it has worked out for yourself? Or have you nevertheless gotten law suites too? Did you have had to pay one fine before? Or would you say I could be one would could go about what you wrote in your post above?

  2. I understand your post. Though, I have had heard from website owners how they have had gotten law suites, usually they do not specify this much further, and other website owners do not mention this at all. So in regards to your post I was not sure if it would work out by doing in that way.

     

    To what type of lawyer may I have to go to?

  3. There are websites like Soundcloud, Soundclick, MySpace and more.

     

    The Question:

    How to not get a law suite as a website owner when copyright protected music or in other words music from the retail has gotten uploaded?

     

    Will moderating it and having it frequently taken down do the job?

     

    I know that the users themselves could get researched too. The site owner could get requested to give out IP addresses. Though, I kept this separately from that question.

     

    I basically would be looking to be safe and not get a law suite.

     

    I would appreciate the suggestions a lot.

  4.  

    Auto Save Plugin for the CKEditor which automatically saves the content (via HTML5 LocalStorage) temporarly (for example when a login session times out). And after the content is saved it can be restored when the editor is reloaded.

    The auto save plugin for CKEditor does its job the way its described in the quote above.

     

    I was wondering if there is a way to have the web based text editor for my blog, the way the Wordpress text editor is, with an auto save (draft) function?

     

    Is there a web based text editor with such function, which would enable me this?

  5. mogosselin, thanks for the response. I also meant using "pdo". Though, as of now, I am using "bindValue()" with this I can freely use SELECT, INSERT, UPDATE and DELETE. So I figured it out "till to this" on how to do this with OOP and prepared statements.

  6. The Connection:

    <?php
    
    $dsn = "mysql:dbname=phpblog;host=localhost";
    $user = "root";
    $password = "";
    try{
        $pdo = new PDO($dsn, $user, $password);
    }catch(PDOException $e){
        echo "Connection failed: " . $e->getMessage();
    }
    
    ?>
    

    The Script:

    <?php
    
    $query = $pdo->prepare("SELECT * FROM posts WHERE id = ?");
    $query->bindValue("1", $_GET['post_id']);
    $query->execute();
    
    ?>
    

    I want to print the column "headline" on screen.

     

    I know how to do it with a foreach loop:

    Example:

    foreach($query as $data){
        echo $data['headline'];
    }
    

    What can I do there?

  7. This UPDATE script works:

    $query = $pdo->prepare("UPDATE posts SET headline = ? WHERE id = ?");
        $query->bindValue("1", $_POST['headline']);
        $query->bindValue("2", "2");
        $query->execute();
    

    Though, this INSERT script does not work:

    $query = $pdo->prepare("INSERT INTO posts (headline, post) VALUES (?, ?)");
        $query->bindValue("1", $_POST['headline']);
        $query->bindValue("2", $_POST['post']);
        $query->execute();
    

    Nothing gets added, when executing this script.

     

    The connection:

    <?php
    
    $dsn = "mysql:dbname=phpblog;host=localhost";
    $user = "root";
    $password = "";
    try{
        $pdo = new PDO($dsn, $user, $password);
    }catch(PDOException $e){
        echo "Connection failed: " . $e->getMessage();
    }
    
    ?>
    

    Any suggestions why the INSERT script is not working?

  8. Hey sorry that I am asking this question, though I have gotten around to learn connecting to a database and also do the retrieve, yet I am not necessarily getting to learn doing INSERT, UPDATE and DELETE the proper way.

     

    The tutorials available are often not best, I have found a good book ("Object Oriented Programming in PHP5") which teaches SELECT, yet not necessarily INSERT, UPDATE and DELETE.

     

    I am really wondering how does one get to learn CRUD with PHP OOP, how did you people learn this? How can I learn INSERT, UPDATE and DELETE as well with PHP OOP?

    I feel like paying for this on Elance or Fiverr. I am not sure how else to learn this by now, I have tried quite a bit, I have looked at scripts and tutorials and books. And it has just gotten as far as connecting to the database and doing the "fetching" ("SELECT", or also "retrieve").

     

    Too bad that what is available is not necessarily best. Otherwise I would say one could understand the principle quickly and also pick up on a programming language quickly.

     

    Please bear with me, I would appreciate suggestions.

  9. The Script:

    pdo_connect.php:

    <?php
    $dsn = "mysql:host=localhost;dbname=2354";
    
    $db = new PDO($dsn, "root", "");
    
    ?>
    

    pdo_test.php:

    <?php
        try{
            require_once("pdo_connect.php");
        }catch(Exception $e){
            $error = $e->getMessage();
        }
    
    ?>
    <!DOCTYPE html>
    <html>
    <head>
        <title>Database Connection with PDO</title>
    
    </head>
    <body>
    <h1>Connection with PDO</h1>
    <?php
        if($db){
            echo "<p>Connection successful.</p>";
        }elseif(isset($error)){
            echo "<p>$error</p>";
        }
    
    ?>
    </body>
    </html>
    
    

    I have just watched a tutorial and tried out this script. The issue is that I am getting the following notice alongside with the error message:

    Notice: Undefined variable: db in C:\xampp\htdocs\oophp\pdo_test.php on line 18
    
    SQLSTATE[HY000] [1049] Unknown database '2354'
    

    By the way this notice does happen in the tutorial as well.

     

    My question is: How to have this in ways, where the notice does not occur?

     

  10. Maybe some experienced people could be letting me know when it comes this?

     

    I thought of a  "file storage" web app like "YouSendIt", I also thought of a "web host" web app as a "reseller".

     

    With this I am getting caught up in thoughts, that the traffic could not happen.

     

    Is there something, where one could be more "sure" that the traffic may happen, and with this the "clicks" too, even if it are a $100 or $200 per month?

     

    I would appreciate the suggestions a lot.

  11. Addendum:

    To what you wrote after that: I did not even think this code would be poor. It also disappoints. On "Stackoverflow" one gets told that "90% of the tutorials out there are poor". I get to think this could be true, yet it also disappoints.

     

    One of the comments on the tutorial:

    This tutorial is rather to confuse newbies and to teach wrong techniques.
    

    I will pay more attention to this.

  12. Its not a good tutorial if it is defining $pdo as global! In fact all it has doing is wrapping procedural code inside of a class.

    Do you have a suggestion? I really am trying to learn OOP. I thought I could be learning good with "CRUD".

    Do you have "something" where I could be seeing the "difference" with what you have had mentioned?

    A boolean value maybe? Return true if the article has been deleted or the article has been updated.
    

    Are you also saying that the "execute" part will do this already? Though, I understand that the return of "true" would happen on success.

     

    ginerjm,

     

    Thanks for the answer. I understand what you are saying, though I thought I could be learning OOP with a "CRUD" tutorial. I also feel like after those few tutorials I could be going ahead and read the books.

  13. Script:

    <?php
    
    class Article{
        public function fetch_all(){
            global $pdo;
    
            $query = $pdo->prepare("SELECT * FROM `articles` ORDER BY `article_timestamp` DESC");
            $query->execute();
    
            return $query->fetchAll();
        }
    
        public function fetch_data($article_id){
            global $pdo;
    
            $query = $pdo->prepare("SELECT * FROM `articles` WHERE `article_id` = ?");
            $query->bindValue(1, $article_id);
            $query->execute();
    
            return $query->fetch();
        }
    
        /*
         * These have gotten added later on.
         */
        
        public function delete($id){
            global $pdo;
    
            $query = $pdo->prepare("DELETE FROM `articles` WHERE `article_id` = ?");
            $query->bindValue(1, $id);
            $query->execute();
    
            // The "return" here.
    
        }
    
        public function edit_page($title, $content, $aticle_id){
            global $pdo;
    
            $query = $pdo->prepare("UPDATE `articles` SET `article_title` = ?, `article_content` = ? WHERE `article_id` = ?");
    
            $query->bindValue(1, $title);
            $query->bindValue(2, $content);
            $query->bindValue(3, $article_id);
    
            $query->execute();
    
            // The "return" here.
        }
    
    }
    
    
    ?>
    

    I have this from a tutorial. In the function "fetch_all()" it uses "fetchAll()" at the spot where the "return" is, and in the function "fetch_data()" it uses "fetch()" at the spot where the "return" is.

     

    My Question:

    What may have to use for the function "delete()" and the function "edit_page()" at the spot where "return" would be?

  14. include($_SERVER['DOCUMENT_ROOT'] . "/cms/includes/header.php");
    
    

    This gets inlucded in a sub directory for example than the stylesheets will not load anymore, when I have used "/" or also "../", that is why I have used "http://localhost/" to load the styelsheets, with that it works then.

     

    This was what I actually meant.

     

    Though, I have had just checked it and using the following indeed works for myself now:

    <link rel="stylesheet" type="text/css" href="/cms/assets/style.css" />
    

    With the "forward slash" at the beginning.

     

    So, basically always starting with the "project name" in the "href" could be working then.

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