Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Including query, bind parameters and bind results

$
0
0
Thank you to everyone who has contributed to any of my other questions. It has helped me to have a much greater understanding of classes, functions and prepared statements - and their purposes. But one last question, cos I just can't put all the pieces together myself!

For the following example of a prepared statement, can somebody show me how I can store the query, bind parameters and bind results valies in a separate file (include.php), include them and "call" them in example.php

include.php
<?php
...
?>
example.php
<?
include 'include.php'
$stmt = $mysqli->prepare("SELECT heading, content FROM miscellaneous WHERE id = ?");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->bind_result($heading, $content);
$stmt->fetch();
$stmt->close();
?>
I would be SO grateful as I have tried to work this out for myself for 3 or 4 days before consulting this forum - with no success!

Viewing all articles
Browse latest Browse all 13200

Trending Articles