0

I am having some issues with some code i am trying to use. Can you please take a look at the code and give me some fixes to this. The error i am getting is this: Warning: Wrong parameter count for mysql_fetch_assoc() in /home/content/33/5271833/html/cfr_forms/edit.php on line 10.

What i am trying to do is display data in a form with the fields listed below. If you know of a simpler way of doing this please let me know. Thanks in advanced.

<?php
include('connect-db.php');

// get value of id that sent from address bar
// get data from db
$getid = $_GET['int'];

// Retrieve data from database 
$sql=mysql_query('SELECT * FROM claim WHERE int = "' . $getid . '"');
$row = mysql_fetch_assoc($query, MYSQL_ASSOC);

$agentdb = $row['agent'];
$cardpullerdb = $row['cardpuller'];
$datedb = $row['date'];
$timedb = $row['time'];
$customerdb = $row['customer'];
$mailonlydb = $row['mailonly'];
$addressdb = $row['address'];
$citydb = $row['city'];
$statedb = $row['state'];
$zipdb = $row['zip'];
$phonedb = $row['phone'];
$faxdb = $row['fax'];
$faxonlydb = $row['faxonly'];
$emaildb = $row['email'];
$amountclaimeddb = $row['amountclaimed'];
$feedb = $row['fee'];
$courierdb = $row['courier'];
$pickupdatedb = $row['pickupdate'];
$pickupcompletedb = $row['pickupcomplete'];
$checkdb = $row['check'];


echo '<form action="edit.php?id=' . $getid . '" method="post"><br />
Agent: <input type="text" name="firstname" value="' . $agentdb . '"><br />
Card Puller: <input type="text" name="firstname" value="' . $cardpullerdb . '"><br />
Date: <input type="text" name="firstname" value="' . $datedb . '"><br />
Time: <input type="text" name="firstname" value="' . $timedb . '"><br />
Customer: <input type="text" name="firstname" value="' . $customerdb . '"><br />
Mail Only: <input type="text" name="firstname" value="' . $mailonlydb . '"><br />
Address: <input type="text" name="firstname" value="' . $addressdb . '"><br />
City: <input type="text" name="firstname" value="' . $citydb . '"><br />
State: <input type="text" name="firstname" value="' . $statedb . '"><br />
Zip: <input type="text" name="firstname" value="' . $zipdb . '"><br />
Phone: <input type="text" name="firstname" value="' . $phonedb . '"><br />
Fax Number: <input type="text" name="firstname" value="' . $faxdb . '"><br />
Fax Only: <input type="text" name="firstname" value="' . $faxonlydb . '"><br />
Email: <input type="text" name="firstname" value="' . $emaildb . '"><br />
Claimed Amount: <input type="text" name="firstname" value="' . $amountclaimeddb . '"><br />
Fee: <input type="text" name="firstname" value="' . $feedb . '"><br />
Courier: <input type="text" name="firstname" value="' . $courierdb . '"><br />
Pick-Up Date: <input type="text" name="firstname" value="' . $pickupdatedb . '"><br />
Pick-Up Completed: <input type="text" name="firstname" value="' . $pickupcompletedb . '"><br />
Check Received (Yes or No): <input type="text" name="firstname" value="' . $checkdb . '"><br />

<input type="submit" name="submit">';

if ($submit)
{

// Edit the data

$updatequery = mysql_query('UPDATE agents SET firstname = "' . $firstname . '" WHERE id = "' . $getid . '"');

echo 'The data has updated successfully.';

}





?>
3
Contributors
3
Replies
6
Views
4 Years
Discussion Span
Last Post by diafol
0
<?php
include('connect-db.php');

// get value of id that sent from address bar
// get data from db
$getid = $_GET['int'];

// Retrieve data from database 
$sql=mysql_query('SELECT * FROM claim WHERE int = "' . $getid . '"');

while ($row = mysql_fetch_assoc($sql)) {
    $agentdb = $row['agent'];
    $cardpullerdb = $row['cardpuller'];
    $datedb = $row['date'];
    $timedb = $row['time'];
    $customerdb = $row['customer'];
    $mailonlydb = $row['mailonly'];
    $addressdb = $row['address'];
    $citydb = $row['city'];
    $statedb = $row['state'];
    $zipdb = $row['zip'];
    $phonedb = $row['phone'];
    $faxdb = $row['fax'];
    $faxonlydb = $row['faxonly'];
    $emaildb = $row['email'];
    $amountclaimeddb = $row['amountclaimed'];
    $feedb = $row['fee'];
    $courierdb = $row['courier'];
    $pickupdatedb = $row['pickupdate'];
    $pickupcompletedb = $row['pickupcomplete'];
    $checkdb = $row['check'];

    echo '<form action="edit.php?id=' . $getid . '" method="post"><br />
    Agent: <input type="text" name="firstname" value="' . $agentdb . '"><br />
    Card Puller: <input type="text" name="firstname" value="' . $cardpullerdb . '"><br />
    Date: <input type="text" name="firstname" value="' . $datedb . '"><br />
    Time: <input type="text" name="firstname" value="' . $timedb . '"><br />
    Customer: <input type="text" name="firstname" value="' . $customerdb . '"><br />
    Mail Only: <input type="text" name="firstname" value="' . $mailonlydb . '"><br />
    Address: <input type="text" name="firstname" value="' . $addressdb . '"><br />
    City: <input type="text" name="firstname" value="' . $citydb . '"><br />
    State: <input type="text" name="firstname" value="' . $statedb . '"><br />
    Zip: <input type="text" name="firstname" value="' . $zipdb . '"><br />
    Phone: <input type="text" name="firstname" value="' . $phonedb . '"><br />
    Fax Number: <input type="text" name="firstname" value="' . $faxdb . '"><br />
    Fax Only: <input type="text" name="firstname" value="' . $faxonlydb . '"><br />
    Email: <input type="text" name="firstname" value="' . $emaildb . '"><br />
    Claimed Amount: <input type="text" name="firstname" value="' . $amountclaimeddb . '"><br />
    Fee: <input type="text" name="firstname" value="' . $feedb . '"><br />
    Courier: <input type="text" name="firstname" value="' . $courierdb . '"><br />
    Pick-Up Date: <input type="text" name="firstname" value="' . $pickupdatedb . '"><br />
    Pick-Up Completed: <input type="text" name="firstname" value="' . $pickupcompletedb . '"><br />
    Check Received (Yes or No): <input type="text" name="firstname" value="' . $checkdb . '"><br />
    <input type="submit" name="submit">';
}

if ($submit)
{
    // Edit the data
    $updatequery = mysql_query('UPDATE agents SET firstname = "' . $firstname . '" WHERE id = "' . $getid . '"');
    echo 'The data has updated successfully.';
}
?>
0

It depends on whether you have unique 'int' in 'claim' as to whether you need a while loop or not. If unique, no need, but I'd limit the recordset to 1 all the same so you stop searching after the hit:

$sql=mysql_query("SELECT * FROM `claim` WHERE `int` = $getid LIMIT 1");
$row = mysql_fetch_assoc($sql);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.