phpnewbfreak Posted April 22, 2014 Share Posted April 22, 2014 (edited) Hey all, I'm trying to edit database data and I keep getting this error Fatal error: Call to a member function prepare() on a non-object on line 4 which is $result = $db->prepare("SELECT * FROM calendar WHERE id= :userid"); Any ideas? <?php include('connect-db.php'); $id=$_GET['id']; $result = $db->prepare("SELECT * FROM calendar WHERE id= :userid"); $result->bindParam(':userid', $id); $result->execute(); for($i=0; $row = $result->fetch(); $i++){ ?> <form action="edit.php" method="POST"> <input type="hidden" name="id" value="<?php echo $id; ?>"/> <div> <p><strong>ID:</strong> <?php echo $id; ?></p> <strong>Program:</strong> <input type="text" name="program" value="<?php echo $program; ?>"/><br/> <strong>Date of Content: </strong> <input type="text" name="airdate" value="<?php echo $airdate; ?>"/><br/> <strong>Description:</strong> <input type="text" name="description" value="<?php echo $description; ?>"/><br/> <strong>On-Air:</strong> <input type="text" name="production" value="<?php echo $production; ?>"/><br/> <strong>Promotion:</strong> <input type="text" name="promotion" value="<?php echo $promotion; ?>"/><br/> <strong>Community:</strong> <input type="text" name="community" value="<?php echo $community; ?>"/><br/> <strong>Web:</strong> <input type="text" name="web" value="<?php echo $web; ?>"/><br/> <input type="submit" name="submit" value="Submit"> <?php } ?> Edited April 22, 2014 by phpnewbfreak Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 22, 2014 Share Posted April 22, 2014 I'm guessing that connect-db.php failed you. The var $db is not a pdo object yet. Do you handle errors in that connect-db module? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.