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.';

}





?>

Recommended Answers

All 3 Replies

Member Avatar for diafol

Try:

$row = mysql_fetch_assoc($sql);
<?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.';
}
?>
Member Avatar for diafol

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.