Jump to content

rawky1976

Members
  • Posts

    108
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rawky1976's Achievements

Member

Member (2/5)

0

Reputation

  1. Fixed it, there were two variables assigned the the fetch_array. Commented the top one out!!! Thank you, Mark
  2. Thanks, here it is: - <?php $connection = mysql_connect("localhost","user","pass"); $select_db = mysql_select_db("dbname", $connection); //$fields = mysql_list_fields("dbname", "tablename", $connection); //$columns = mysql_num_fields($fields); $query = "select * from dbname.tablename ORDER BY fieldname"; $result = mysql_query($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); $columns = mysql_fetch_array($result); echo "System Name: <select name=Field>"; while ($row= mysql_fetch_array($result)) { echo "<option value={$row[4]}>"; echo $row[0]; echo "</option>"; } echo "</select>"; ?>
  3. OK, I figured that part out, but I'm only getting one row from the table, I need all of them please? Thank you, Mark
  4. Thanks, I'm now getting undefined output on echo $row[1]; Is it because I'm only selecting one field and not *?
  5. Hi all; hope you're well!!!! I found a script that displays the field names from a table in a drop-down but I want to show the values in that field. I've tried to amend that script but think I've got the logic of the functions incorrect. Thanks for any help you might be able to offer <?php $connection = mysql_connect("localhost","xxx","xxx"); $select_db = mysql_select_db("dbname", $connection); //$fields = mysql_list_fields("dbname", "tablename", $connection); //$columns = mysql_num_fields($fields); $query = "select field from dbname.table ORDER BY field"; $result = mysql_query($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); $columns = mysql_fetch_array($result); echo "System Name: <select name=Field>"; for ($i = 0; $i < $columns[$num_rows]; $i++) { echo "<option value=$i>"; //echo mysql_field_name($fields, $i); } echo "</select>"; ?>
  6. Hello again! I've been looking into this and I think I've discovered the problem. The recno value comes as a GET from the previous page. When the form is submitted it POSTS, so the recno doesn't get populated when it reloads. I've therefore updated the script as below. I've used another hidden field in the form and tried to assign the recno value to it for the post. I've also added an elseif at the top to catch both GET and POST. I'm not sure whether you can do it that way though? Is the syntax correct for my new hidden field? <?php include 'library/config.php'; include 'library/opendb.php'; // check if rec no is set or not... if (isset($_GET['recno'])) { //$recno = (int) $_GET['recno']; $recno = $_GET['recno']; } elseif (isset($_POST['recno'])){ $recno = $_POST['recno']; } // from here you are trying to delete the record... if (isset($_POST['submitted'])) { $query = "DELETE FROM knowledgebase.document WHERE document_id='$recno'"; $result = mysql_query($query) or die(mysql_error()); echo 'The record was sucessfully removed'; include ('./library/cpfooter.html'); exit(); } //query $query_sel = "select * from document WHERE document_id = '$recno'"; $result_sel = mysql_query($query_sel) or die(mysql_error()); // if result found if ($result_sel) { $r = mysql_fetch_array($result_sel); $dn = $r['document_name']; } ?> <form action="confirmdelete.php" method="post"> <fieldset><legend>Confirm Record Deletion</legend> <p>Are you sure you wish to remove the record for the document: -<br /> <?php echo "$dn"; ?><br /><br /> <input type="submit" value="Yes Delete Record"><input type="hidden" name="submitted" value="TRUE" /><input type="hidden" name="recno" value="$recno"> </fieldset> </form>
  7. I just thought, running in Query Browser is from the MySQL root login right? Does the application run under some other login that doesn't have permission to delete? Would that show up in the 'or die'?
  8. This is strange, I've ran the query through the Query Browser and it deletes the record. It can only be the variable and that is used successfully in the SELECT statement above?
  9. Thanks, I think the code I have for that bit does work though, I've used it throughout the application (got it from a book!)
  10. Hello, thanks for the response. I now get the filename displayed on the confirm delete page ($dn is being assigned and displayed). The delete success message is displayed but the record still isn't actually deleted. I'll double check the fieldnames etc. Mark
  11. Hello all I'm having a little trouble with the code below. I think it's either that the braces are misplaced or the statements are in the wrong order. In the form if I echo'$recno' then I get the number that was passed from the previous page, but when I change it to echo'$dn' it's just blank. Is the variable not in scope of the form? Also when the form is submitted the message that the record has been deleted is displayed, although it hasn't actually been deleted? Thanks for any help you can offer, Mark <h2>Confirm Record Delete</h2> <?php if (isset($_GET['recno'])) { $recno = (int) $_GET['recno']; } include 'library/config.php'; include 'library/opendb.php'; $query = "select * from document WHERE document_id = '$recno'"; $result = mysql_db_query($query); if ($result) { $r = mysql_fetch_array($result); $dn = $r["document_name"]; } if (isset($_POST['submitted'])) { $query = "DELETE FROM document WHERE document_id=$recno"; if (mysql_num_rows($result) == 1) { $result = mysql_query($query); } echo 'The record was sucessfully removed'; include ('./library/cpfooter.html'); exit(); } ?> <form action="confirmdelete.php" method="post"> <fieldset><legend>Confirm Record Deletion</legend> <p>Are you sure you wish to remove the record for the document: -<br /><br /> <?php echo "$dn"; ?><br /><br /> <input type="submit" value="Yes Delete Record"><input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form>
  12. It's not being used elsewhere at all. I commented out the function and removed the calls from the script and it drags the correct fields into the variables. The SELECT still fails but that's something else for me to ponder over! Thanks for you help, Mark
  13. Before shows my email address!!! After shows: - AFTER: TEST E: TEST P: Here is the function (it's out of a book). function escape_data ($data) { global $dbc; if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } return mysql_real_escape_string(trim($data), $dbc); } Thanks again, Mark
  14. OK thanks, I added: - echo "TEST E: $e"; echo "TEST P: $p"; and it outputs: - TEST E: TEST P: The email address and current password do not match those in the database. SELECT userid FROM knowledgebase.users WHERE email='' AND password='' Is it a setting with the quotes or something rather than the script?
  15. The code for $p is the same as $e but for password field instead of email. I've added the die but it hasn't printed any errors on the page: - $query = "SELECT userid FROM knowledgebase.users WHERE email='$e' AND password='$p'"; $result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());
×
×
  • 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.