Hi,

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 :))

        <?php
        //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

        ///////////////Values///////////////////
            $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) {
            mysqli_fetch_assoc($ChangeDownloadSQL){
            echo "Changed Details";
        } else {
            echo "Failed";
            }
        }
        //CRONJOBCHECK//
        //$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;
            }
        }else{
            //Display Error Message
            echo '<p>';
            echo mysqli_error($db);
            echo '</p>';
        }

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

Line 22:

mysqli_fetch_assoc($ChangeDownloadSQL){

You should terminate it with ;

if ($Changers) {
            mysqli_fetch_assoc($ChangeDownloadSQL);
            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.

Thanks!

Be a part of the DaniWeb community

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