RE: [PHP-DB] MySQL Returns Error
-Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:52 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Oops, my mistake, it's not a blank entry - it re enters the last entry. I can hit F5 or click refresh 1000 times and it will enter the last entry 1000 times. The simplest thing to do is do a header('Location: http://your.site.com/someOtherPage.php') after the insert. That way the page displayed isn't the one someone will hit refresh on. Otherwise, perhaps you should do a select to see if the value is already in the db, and if so, don't insert it again, but perhaps update it, or ignore it. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
On Wednesday 06 August 2003 01:14, Jeff wrote: Well I did what you said, and now I get Parse error: parse error, unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44 Try: $result = mysql_query($query, $link_id) OR die(mysql_error()); -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Byte your tongue. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
-Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method=post // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
So create a hidden input field on the page called cur_id and set its value to the id of the record being displayed. If no record is currently being displayed, set it to -1. When you get ready to handle the form data, check the $_POST['cur_id'] variable. If it's set to -1, perform an INSERT. If it's set to anything else, perform an UPDATE using the value of $_POST['cur_id'] in your WHERE clause. I'm sure there are other ways to handle this. This is how I have handled it in the past though. -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:52 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Oops, my mistake, it's not a blank entry - it re enters the last entry. I can hit F5 or click refresh 1000 times and it will enter the last entry 1000 times. Jeff [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I tried putting that in a few diffrent places, same result - is there somewhere special I need to put that? Matt Schroebel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method=post // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
if i understand your question. why not take a different approach. when the form is submitted do your updates/inserts and then forward the page with the header() function to another page, even if it is the same page, but with a different set of variables set on the page, the idea being to remove the $_POST/$_GET arrays containing your data so at the end of your insert header(Location: .$_SERVER['PHP_SELF'].?inserted=true); you can send them from whence they came with header(Location: .$_SERVER['HTTP_REFERER']); hth jd Jeff [EMAIL PROTECTED]To: [EMAIL PROTECTED] cc: Subject: Re: [PHP-DB] MySQL Returns Error 08/05/2003 06:41 PM I'm unsure of both suggestions, can someone go into more detail? Richard Hutchins [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So create a hidden input field on the page called cur_id and set its value to the id of the record being displayed. If no record is currently being displayed, set it to -1. When you get ready to handle the form data, check the $_POST['cur_id'] variable. If it's set to -1, perform an INSERT. If it's set to anything else, perform an UPDATE using the value of $_POST['cur_id'] in your WHERE clause. I'm sure there are other ways to handle this. This is how I have handled it in the past though. -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:52 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Oops, my mistake, it's not a blank entry - it re enters the last entry. I can hit F5 or click refresh 1000 times and it will enter the last entry 1000 times. Jeff [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I tried putting that in a few diffrent places, same result - is there somewhere special I need to put that? Matt Schroebel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method=post // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
I tried putting that in a few diffrent places, same result - is there somewhere special I need to put that? Matt Schroebel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method=post // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
Oops, my mistake, it's not a blank entry - it re enters the last entry. I can hit F5 or click refresh 1000 times and it will enter the last entry 1000 times. Jeff [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I tried putting that in a few diffrent places, same result - is there somewhere special I need to put that? Matt Schroebel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method=post // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
I'm unsure of both suggestions, can someone go into more detail? Richard Hutchins [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So create a hidden input field on the page called cur_id and set its value to the id of the record being displayed. If no record is currently being displayed, set it to -1. When you get ready to handle the form data, check the $_POST['cur_id'] variable. If it's set to -1, perform an INSERT. If it's set to anything else, perform an UPDATE using the value of $_POST['cur_id'] in your WHERE clause. I'm sure there are other ways to handle this. This is how I have handled it in the past though. -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:52 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Oops, my mistake, it's not a blank entry - it re enters the last entry. I can hit F5 or click refresh 1000 times and it will enter the last entry 1000 times. Jeff [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I tried putting that in a few diffrent places, same result - is there somewhere special I need to put that? Matt Schroebel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method=post // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
-Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 12:59 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL Returns Error Been working on this code all weekend, and I did take everyone's advice, but I'm still getting the same error. Error retrieving records. From line $result = mysql_query($query, $link_id) OR DIE(Error retrieving records.); of my code. When I first put the insert query in, it allowed me to add one record, then started returning the error, and hasn't let me enter another record since. Change that line to: $result = mysql_query($query, $link_id) OR DIE(echo mysql_error()); Make sure you either have magic_quotes_gpc on or (better) have magic_quotes_gpc off and addslashes() to each of the values you're inserting into the db. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
UNIQUE gradient (gradient) This is causing your issue. You have stated that new records cannot match an already established record with the same name under gradient. HTH Aaron -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: August 5, 2003 1:44 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Ok, that worked, Now the error I'm getting is Duplicate entry ' ' for key 1 Is this a SQL table error? Here's my Table as entered: CREATE TABLE gradients ( gradient MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, kwo VARCHAR(10) NOT NULL, lsd VARCHAR(10) NOT NULL, date DATE DEFAULT '-00-00' NOT NULL, well VARCHAR(50) NOT NULL, field VARCHAR(25) NOT NULL, uni VARCHAR(30) NOT NULL, license VARCHAR(10) BINARY NOT NULL, formation VARCHAR(20) NOT NULL, perfs VARCHAR(20) NOT NULL, event VARCHAR(1) NOT NULL, fluid VARCHAR(2) NOT NULL, mode VARCHAR(2) NOT NULL, type VARCHAR(2) NOT NULL, vhd VARCHAR(10) NOT NULL, file VARCHAR(15) NOT NULL, kb VARCHAR(6) NOT NULL, grd VARCHAR(10) NOT NULL, open VARCHAR(1) NOT NULL, sour VARCHAR(1) NOT NULL, tube VARCHAR(10) NOT NULL, landed VARCHAR(6) NOT NULL, casing VARCHAR(6) NOT NULL, landed2 VARCHAR(6) NOT NULL, shut_date VARCHAR(10) NOT NULL, shut_time DATE DEFAULT '-00-00' NOT NULL, pres VARCHAR(15) NOT NULL, tag VARCHAR(15) NOT NULL, PRIMARY KEY (lsd), UNIQUE gradient (gradient) ); Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Wednesday 06 August 2003 01:14, Jeff wrote: Well I did what you said, and now I get Parse error: parse error, unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44 Try: $result = mysql_query($query, $link_id) OR die(mysql_error()); -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Byte your tongue. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
Change the gradient definition to: gradient MEDIUMINT(10) NOT NULL AUTO_INCREMENT, -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 1:44 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Ok, that worked, Now the error I'm getting is Duplicate entry ' ' for key 1 Is this a SQL table error? Here's my Table as entered: CREATE TABLE gradients ( gradient MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, . tag VARCHAR(15) NOT NULL, PRIMARY KEY (lsd), UNIQUE gradient (gradient) ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
Ok, that worked, Now the error I'm getting is Duplicate entry ' ' for key 1 Is this a SQL table error? Here's my Table as entered: CREATE TABLE gradients ( gradient MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, kwo VARCHAR(10) NOT NULL, lsd VARCHAR(10) NOT NULL, date DATE DEFAULT '-00-00' NOT NULL, well VARCHAR(50) NOT NULL, field VARCHAR(25) NOT NULL, uni VARCHAR(30) NOT NULL, license VARCHAR(10) BINARY NOT NULL, formation VARCHAR(20) NOT NULL, perfs VARCHAR(20) NOT NULL, event VARCHAR(1) NOT NULL, fluid VARCHAR(2) NOT NULL, mode VARCHAR(2) NOT NULL, type VARCHAR(2) NOT NULL, vhd VARCHAR(10) NOT NULL, file VARCHAR(15) NOT NULL, kb VARCHAR(6) NOT NULL, grd VARCHAR(10) NOT NULL, open VARCHAR(1) NOT NULL, sour VARCHAR(1) NOT NULL, tube VARCHAR(10) NOT NULL, landed VARCHAR(6) NOT NULL, casing VARCHAR(6) NOT NULL, landed2 VARCHAR(6) NOT NULL, shut_date VARCHAR(10) NOT NULL, shut_time DATE DEFAULT '-00-00' NOT NULL, pres VARCHAR(15) NOT NULL, tag VARCHAR(15) NOT NULL, PRIMARY KEY (lsd), UNIQUE gradient (gradient) ); Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Wednesday 06 August 2003 01:14, Jeff wrote: Well I did what you said, and now I get Parse error: parse error, unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44 Try: $result = mysql_query($query, $link_id) OR die(mysql_error()); -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Byte your tongue. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php