benjamin_boothe Posted August 23, 2006 Share Posted August 23, 2006 I'm trying to edit records from the web. I can display the list of records, but I can't display the lists of records to edit.I am trying to display the records with the use of an id.Basically, I trying to SELECT a record WHERE id=$id.Here is the code:[code]<!--set up the table --><TABLE BORDER="1" CELLPADDING="5"><TR> <TH>Title</TH> <TH>First name</TH> <TH>Last name</TH> <TH>Date of birth</TH> <TH>UK residency</TH> <TH>Marital status</TH> <TH>Disability</TH> <TH>Employment status</TH> <TH>Address line 1</TH> <TH>Area</TH> <TH>Town</TH> <TH>County</TH> <TH>Post code</TH> <TH>Telephone work</TH> <TH>Telephone home</TH> <TH>Fax number</TH> <TH>Email</TH> </TR><?$id = isSet($_POST['id']) ? $_POST['id'] : '';include 'includes/db_conn.txt';// build and execute the query $select = "SELECT title, first_name, surname, date_of_birth, uk_residency, marital_status, disability, employment_status, address_line_1, area, town, county, post_code, telephone_work, telephone_home, fax_number, email FROM policy_holder WHERE id=$id"; $result= mysqli_query($link, $select);while ($row = mysqli_fetch_array($result)) { $t = $row['title']; $fn = $row['first_name']; $sn = $row['surname']; $dob = $row['date_of_birth']; $uk = $row['uk_residency']; $ms = $row['marital_status']; $d = $row['disability']; $es = $row['employment_status']; $ad1 = $row['address_line_1']; $a = $row['area']; $tn = $row['town']; $c = $row['county']; $pc = $row['post_code']; $tw = $row['telephone_work']; $th = $row['telephone_home']; $fax = $row['fax_number']; $em = $row['email']; $id = $row['id']; echo <<<END<TR> <TD>$t</TD> <TD>$fn</TD> <TD>$sn</TD> <TD>$dob</TD> <TD>$uk</TD> <TD>$ms</TD> <TD>$d</TD> <TD>$es</TD> <TD>$ad1</TD> <TD>$a</TD> <TD>$tn</TD> <TD>$c</TD> <TD>$pc</TD> <TD>$tw</TD> <TD>$th</TD> <TD>$fax</TD> <TD>$em</TD> <TD><a href="mysqli_list_update.php?id=$id">Edit details</a></TD></TR>END;}?><!-- Close table --></TABLE>[/code]I get this message when I trying to run it:[quote]Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in E:\Program Files\Apache Group\Apache2\htdocs\policylist.php on line 40[/quote]Help me please!!! Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/ Share on other sites More sharing options...
hitman6003 Posted August 23, 2006 Share Posted August 23, 2006 change this line:[code]$result= mysqli_query($link, $select);[/code]to:[code]$result= mysqli_query($link, $select) or die(mysqli_error());[/code]And let us know what the output is then. Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79540 Share on other sites More sharing options...
trq Posted August 23, 2006 Share Posted August 23, 2006 It appears your query is failing and that $result holds the value of FALSE. Try some error handling to try and track down the problem.[code=php:0]$result= mysqli_query($link, $select) or die(mysqli_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79541 Share on other sites More sharing options...
benjamin_boothe Posted August 23, 2006 Author Share Posted August 23, 2006 This is the error that I get now:[quote]Warning: mysqli_error() expects exactly 1 parameter, 0 given in E:\Program Files\Apache Group\Apache2\htdocs\policylist.php on line 38[/quote]What does this mean I have to do? Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79547 Share on other sites More sharing options...
hitman6003 Posted August 23, 2006 Share Posted August 23, 2006 supply the connection name...looks like "$link"so it should be:[code]$result= mysqli_query($link, $select) or die(mysqli_error($link));[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79548 Share on other sites More sharing options...
pocobueno1388 Posted August 24, 2006 Share Posted August 24, 2006 I think you guys are spelling mysql wrong...I am not sure if 'mysqli' is just a different way or not...but if it isn't the code should be:[code]$result= mysql_query($link, $select) or die(mysql_error($link));[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79643 Share on other sites More sharing options...
hitman6003 Posted August 24, 2006 Share Posted August 24, 2006 http://www.php.net/mysqliWhen in doubt....look in the manual Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79647 Share on other sites More sharing options...
benjamin_boothe Posted August 24, 2006 Author Share Posted August 24, 2006 This is the error I get now with adding - $result= mysql_query($link, $select) or die(mysql_error($link));[quote]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4[/quote]I don't know where it is referring to. Can somebody look at my code to see where the problem is.Look above in the post to see my code for the list page. Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79777 Share on other sites More sharing options...
hitman6003 Posted August 24, 2006 Share Posted August 24, 2006 echo out your query so you can see what it is that is causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79810 Share on other sites More sharing options...
trq Posted August 24, 2006 Share Posted August 24, 2006 Just a guess, but Im thinking $id might not be getting populated. As hitman said, echo() your query and lets take a look. Quote Link to comment https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/#findComment-79813 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.