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




Edited by phpnewbfreak
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.