Been working on this PHP snippet and it was fine until I changed one line. I am doing this inside Wordpress so I can't echo the problems out.

"Server error"

Hopefull you guys can see where my snippet has gone wrong :))

        //Create connection
        //new mysqli("localhost", "user", "password", "database");
        $db = mysqli_connect("localhost", "ebook","Password", "Ebook") or die("Cannot Connect to the database");

        //Adding Sent Over Data

            $value_name = $_POST['Name'];
           $value_email = $_POST['Email'];
        $value_category = $_POST['Category'];
        $value_download= $row['Download'];

        $ChangeDownloadSQL = "SELECT Name FROM details WHERE Download=1 UPDATE Download=0";
        $Changers = mysqli_query($db, $ChangeDownloadSQL);

        if ($Changers) {
            echo "Changed Details";
        } else {
            echo "Failed";
        //$sqlquery = "SELECT ID, Name FROM details WHERE Download=0";
        $strSQL = "SELECT Name FROM details WHERE Download=1";
        //RS = Record Set
        $rs = mysqli_query($db, $strSQL);
        if ( $rs) {

            while($row = mysqli_fetch_assoc($rs)){
               echo "<p>" . $row['Name'] . " " . "</p>";
               echo $value_download;
            //Display Error Message
            echo '<p>';
            echo mysqli_error($db);
            echo '</p>';

        echo "<p>" . $row['ID'] . $row['Name'] . "</p>";

Recommended Answers

All 2 Replies

Line 22:


You should terminate it with ;

if ($Changers) {
            echo "Changed Details";
        } else {
            echo "Failed";

This fixed it, I am getting "Failed" come up now and information not being submitted to the db but that's another story :P

I'l get to work on that.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.