Jump to content

alicedavidson

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by alicedavidson

  1. I can't find two instances of db_config.php on any one file. Could the problem be to do with me including 3 function.php files that all all have 'require("db_config.php") inside them? If so, is there a fix or is there a way I can also disable error reporting? Thanks!
  2. Hi again I have moved my DB and project onto my laptop, however when I run two of my pages I am getting spammed by the following... Notice: Consant_ DB_HOST already defined in c:\xampp\htdocs\p1\db_config.php on line 2 Notice: Consant_ DB_USER already defined in c:\xampp\htdocs\p1\db_config.php on line 3 Notice: Consant_ DB_NAME already defined in c:\xampp\htdocs\p1\db_config.php on line 4 Notice: Consant_ DB_PASSWORD already defined in c:\htdocs\p1\db_config.php on line 5 Notice: Consant_ DB_HOST already defined in c:\xampp\htdocs\p1\db_config.php on line 2 Notice: Consant_ DB_USER already defined in c:\xampp\htdocs\p1\db_config.php on line 3 Notice: Consant_ DB_PASSWORD already defined in c:\xampp\htdocs\p1\db_config.php on line 4 The notices are dropped in just after my include statements. This doesnt happen on my other PC and only occurs on two of my pages.The other pages work just fine. What gives? Thanks!
  3. Hi I am trying to delete a row based on a user selection. I have a bit of code here that is giving me "SQL Insertion error: 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 1" I'm not quite sure whats going on but the I have a PHP form and a PHP function and I'm thinking my logic is incorrect. User selects non primary key field from drop down box, submits. Passes the primary key, and other fields to the delete_total function. function delete_total($meid, $mid, $total, $comments, $ename) { $esc_meid = mysql_real_escape_string($meid, $this->conn); $esc_mid = mysql_real_escape_string($mid, $this->conn); $esc_total = mysql_real_escape_string($total, $this->conn); $esc_comments = mysql_real_escape_string($comments, $this->conn); $esc_ename = mysql_real_escape_string($ename, $this->conn); $sql = "DELETE FROM memberevent WHERE meid = $meid"; $result = mysql_query($sql, $this->conn); if (!$result) { die("SQL Insertion error: " . mysql_error()); } else { $numofrows = mysql_affected_rows($this->conn); return $numofrows; } } Now, should I be actually selecting the PRIMARY key on the selection form, and not another field? I selecting a non primary key field because on a drop down 'meid' makes less sense to the user then the 'name' . mysql v 5.1.41
  4. Hi Keith..I'm sorry if I sound dumb but I don't really know what you mean. What I think is the problem is the auto increment bit, and that is somehow conflicting with an existing value. It's as if it's trying to auto increment when I am simply trying to make a change to an existing ID and the rest of it's corrosponding field.
  5. Hi, I have a form that allows me to insert comments and a total, however once I delete a comment or total I can no longer re-insert a new total or comment. I simply get : SQL Insertion error: Duplicate entry 'xx for key 'PRIMARY'. I am using the myisam engine. MySQL Server version: 5.1.41 The table consists of 4 fields. MID : Int (primary autonumber) EID, : Int Total, :text Comment. :text I have two other tables. Member, primary key is mid (member id) and Event primary key is eid (event ID). I dont think I have them relational though. This is my insert function for the update causing dupe error. function insert_me($mid, $eid, $total, $comments) { $esc_mid = mysql_real_escape_string($mid, $this->conn); $esc_eid = mysql_real_escape_string($eid, $this->conn); $esc_total = mysql_real_escape_string($total, $this->conn); $esc_comments = mysql_real_escape_string($comments, $this->conn); $sql = "insert into memberevent (mid, eid, total, comments) values ('{$esc_mid}', '{$esc_eid}', '{$esc_total}', '{$esc_comments}')"; $result = mysql_query($sql, $this->conn); if (!$result) { die("SQL Insertion error: " . mysql_error()); } else { $numofrows = mysql_affected_rows($this->conn); return $numofrows; } } This is the page side code : Enter lifter total:<input type="text" name="total" id="total" /><br /> Enter comment:<input type="text" name="comments" id="total"/><br /> <input type="submit" value="Save" /> </form> <?php } else//post it into database { $mid = $_POST['mid']; $eid = $_POST['eid']; $total = $_POST['total']; $comments = $_POST['comments']; $db1 = new dbme(); $db1->openDB(); $numofrows = $db1->insert_me($mid, $eid, $total, $comments); echo "Success. Number of rows affected: <strong>{$numofrows}<strong>"; $db1->closeDB(); } ?>
×
×
  • 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.