Jump to content

mysqli prepared statements help


ccirish
Go to solution Solved by Barand,

Recommended Posts

Try though I might I cannot find a solution to this problem. When replacing ? with an actual value it works fine. Why can't I get bind_param to work with this? What am I doing wrong? 

 

Thanks.

<?php
//Config Settings
 $mysqli = new mysqli("localhost", "a", "b", "c");
 $TeamID = $_GET["TeamID"];

//Check that we have a DB
 if (!$mysqli)
 {
        printf("Connect failed: %s\n", mysqli_connect_error);
        exit();
 }

//StartHTML
 header("Content-Type: application/xml; charset=ISO-8859-1");
 echo '<?xml version="1.0" encoding="ISO-8859-1" ?>
 <rss version="2.0">
 <channel>
 <title>Title</title>
 <link>Link</link>
 <description>Description</description>';

//Pull Data
 $stmt = $mysqli->stmt_init();
 if ($stmt = $mysqli->prepare("SELECT title, link, description FROM ( ? )"))
 {
        $stmt->bind_param('s', $TeamID);
        $stmt->execute();
        $stmt->fetch();
        $stmt->bind_result($title, $link, $description);
 }
 else
 {
        echo $mysqli->error;
 }

//Loop Through Data
 while ($stmt->fetch())
 {
        echo '<item>
        <title>'.$title.'</title>
        <link>'.$link.'</link>
        <description>'.$description.'</description>
        </item>';
 }

//Shut this bitch down
 $stmt->close();
 $mysqli->close();
 echo '</channel></rss>';
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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