careym1989 Posted September 12, 2008 Share Posted September 12, 2008 When I visit these pages using my own content management system, they both appear to be blank. Here's the code for the view records page: <?php echo '<h1>VIEW CANDIDATES</h1>'; require_once('../mysqli_connect.php'); $q = "SELECT n, cc, st, ea, cd, url, approved FROM candidatesubmit ORDER BY id DESC"; $r = @mysqli_query ($dbc, $q); $num = mysqli_num_rows($r); if ($num > 0) { echo 'There are currently $num candidate records. Some pending, some approved'; echo '<table align="center" cellspacing="3" cellpadding="3" width="100%"> <tr> <td align="left"><b>Edit</b></td> <td align="left"><b>Name</b></td> <td align="left"><b>City County</b></td> <td align="left"><b>State</b></td> <td align="left"><b>Email</b></td> <td align="left"><b>CurrentlyRunningorOfficeHeld</b></td> <td align="left"><b>URL</b></td> <td align="left"><b>approved?</b></td> </tr> '; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr> <td align="left"><a href="ff_Edit.php?id=' . $row['id'] . '">Edit</a></td> <td align="left">' . $row['n'] . '</td> <td align="left">' . $row['cc'] . '</td> <td align="left">' . $row['st'] . '</td> <td align="left">' . $row['ea'] . '</td> <td align="left">' . $row['cd'] . '</td> <td align="left">' . $row['url'] . '</td> <td align="left">' . $row['approved'] . '</td> </tr> '; } echo '</table>'; mysqli_free_result ($r); } else { echo 'There are no registered users'; } mysqli_close($dbc); ?> And here's the code for edit record: <?php echo '<h1>Edit a User</h1>'; if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { echo 'This page has been accessed in error'; exit(); } require_once('../mysqli_connect.php'); if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['n'])) { $errors[] = 'You did not enter a name.'; } else { $n = mysqli_real_escape_string($dbc, trim($_POST['n'])); } if (empty($_POST['cc'])) { $errors[] = 'You did not enter a City or County.'; } else { $cc = mysqli_real_escape_string($dbc, trim($_POST['cc'])); } if (empty($_POST['st'])) { $errors[] = 'You did not enter a State.'; } else { $st = mysqli_real_escape_string($dbc, trim($_POST['st'])); } if (empty($_POST['ea'])) { $errors[] = 'You did not enter an email address.'; } else { $ea = mysqli_real_escape_string($dbc, trim($_POST['ea'])); } if (empty($_POST['cd'])) { $errors[] = 'You did not enter an office seeking or currently held.'; } else { $cd = mysqli_real_escape_string($dbc, trim($_POST['cd'])); } if (empty($_POST['url'])) { $errors[] = 'You did not enter a website.'; } else { $url = mysqli_real_escape_string($dbc, trim($_POST['url'])); } if (empty($errors)) { $q = "SELECT id FROM candidatesubmit WHERE ea='$ea' AND id != $id"; $r = @mysqli_query($dbc, $q); if (mysqli_num_rows($r) == 0) { $q = "UPDATE candidatesubmit SET n='$n', cc='$cc', st='$st', ea='$ea', cd='$cd', url='$url', approved='$approved' WHERE id=$id LIMIT 1"; $r = @mysqli_query ($dbc, $q); if (mysqli_affect_rows($dbc) == 1) { echo 'The record has been edited.'; } else { echo 'The record could not be edited due to a system error. Try again in a couple of hours.'; } } else { echo 'The email address has already registered.'; } } else { echo 'The following errors occurred'; echo 'You messed up, Carey'; } echo ' Please try again.'; } $q = "SELECT n, cc, st, ea, cd, url, approved FROM candidatesubmit WHERE id=$id"; $r = @mysqli_query ($dbc, $q); if (mysqli_num_rows($r) == 1) { $row = mysqli_fetch_array ($r, MYSQLI_NUM); echo '<form action="edit_user.php" method="post"> Name <input type="text" name="n" value="' . $row[0] . '" /> <br> City County Come from <input type="text" name="cc" value="' . $row[1] . '" /> <br> State <input type="text" name="st" value="' . $row[2] . '" /> <br> Email <input type="text" name="ea" value="' . $row[3] . '" /> <br> Office held or currently running for <input type="text" name="cd" value="' . $row[4] . '" /> <br> URL <input type="text" name="url" value="' . $row[5] . '" /> <br> Approved? <input type="text" name="approved" value="' . $row[6] . '" /> <br> <input type="submit" name="submit" value="Submit" /> <br> <input type="hidden" name="submitted" value="TRUE" /> <br> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { echo 'This page has been accessed in error.'; } mysqli_close($dbc); ?> Any help would be greatly appreciated. Regards, Carey Quote Link to comment https://forums.phpfreaks.com/topic/124000-view-records-edit-records-display-blank/ Share on other sites More sharing options...
pocobueno1388 Posted September 13, 2008 Share Posted September 13, 2008 There should be no reason for it to be blank. Is it COMPLETELY blank, or do you at least see the text on the top of the page that says "VIEW CANDIDATES"? Try adding this to the top of your script error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/124000-view-records-edit-records-display-blank/#findComment-640253 Share on other sites More sharing options...
careym1989 Posted September 13, 2008 Author Share Posted September 13, 2008 I do see "VIEW CANDIDATES." Quote Link to comment https://forums.phpfreaks.com/topic/124000-view-records-edit-records-display-blank/#findComment-640261 Share on other sites More sharing options...
pocobueno1388 Posted September 13, 2008 Share Posted September 13, 2008 Maybe there is an error in your query for the view records script. Try changing $r = @mysqli_query ($dbc, $q); To $r = mysqli_query ($dbc, $q)or die(mysql_error()); I'm not familiar with using "mysqli", so hopefully the error function is the same. Also, is there a reason your suppressing errors with the @? Quote Link to comment https://forums.phpfreaks.com/topic/124000-view-records-edit-records-display-blank/#findComment-640279 Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 The function is mysqli_error() when coded procedurally. In OOP it's $mysqli->error;. I prefer the latter. xD Quote Link to comment https://forums.phpfreaks.com/topic/124000-view-records-edit-records-display-blank/#findComment-640281 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.