Jump to content

Edit form with PHP


phpnewbfreak

Recommended Posts

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
    }
?>




Link to comment
https://forums.phpfreaks.com/topic/287946-edit-form-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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