Forum Moderators: open

Message Too Old, No Replies

PHP/MySQL error with script

Please Help me

         

siddiq ijiff

8:12 pm on Oct 24, 2007 (gmt 0)

10+ Year Member



hello all,
i am very new here its my 1st topic,
i got a issue, there is a php scripe created by me its a very simple mysql INSERT script and only for my own use, i am using it to update new and other things, its working fine but before one day i got the error on it but withour editing the script, issue is when i try to add a row like that
mysql_query("INSERT INTO example VALUES ('id','$text')");
so its add but two times, output look like
1, text
2, text
--- already restarted mysql many time and also checked the script, i think issue is from server not from script
can any one tell me how to solve this issue

here full script
----
session_start();
@header("Cache-control: private");
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
$username ="username";
$password ="password";
$databasename ="databasename";
$host ="localhost";
mysql_connect($host, $username, $password) or die();
mysql_select_db("$databasename") or die("error");
mysql_query("INSERT INTO example VALUES ('id','$text')");
echo "added";

--Admin please move it to another place if this place is wrong--

physics

10:56 pm on Oct 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi siddiq_ijiff, welcome to WebmasterWorld.com!

i got the error on it

Did mysql output an error or is there just a problem with what is being done by the insert?

It sounds to me like you are getting duplicate inserts and you only want one. If this is the case one solution is to add a distinct index on the field where you're putting $text into. Another is to solve the problem in PHP and have it check if the text exists in the db yet and not insert if it does.

Does that help?

siddiq ijiff

7:32 am on Oct 25, 2007 (gmt 0)

10+ Year Member



can you please write the details i cant understand properly i want some more details where i can add new etc...

Habtom

7:45 am on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If what you posted is all you have got on the page, the only way you can have duplicate rows is when you refresh the page. It will keep on adding it to the table everytime you refresh the page.

And by the way, I know you just began but
> I wouldn't extract and begin using the values in that way, for security reasons.
> I wouldn't put the connection that way, rather I would put on a separate page and include it when needed

siddiq ijiff

2:08 pm on Oct 25, 2007 (gmt 0)

10+ Year Member



NO YOU ARE NOT RITE
i am not doing with any html form i am doing like that
http://example.com/data.php?text=text here < after opening it i well just close the browser, no refresh no thing, and it was working fine, but now i got the duplicate inserts, i think issue from /tmp because,
i was try to do the zip on the fly and the zip size is 20gb , tmp total size is 10gb so tmp was full and then i got this issue may be its from /tmp.
i dont no many things about tmp let me know is it from tmp if yes so how i can solve the issue...

Habtom

2:25 pm on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:)

whoisgregg

2:27 pm on Oct 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are doing direct entry into your browser address bar, perhaps your browser or a plugin is doing a duplicate request? Some plugins will pass the URL to a third-party service that "pings" the URL to get more information.

Have you recently installed any toolbars or plugins? Can you check your server logs to see if any of the requests for /data.php?text=whatever are coming from an IP other than your own?

To avoid this, make an HTML form that you use that uses POST instead of GET to pass the data.

siddiq ijiff

4:26 pm on Oct 25, 2007 (gmt 0)

10+ Year Member



Thank You very much "whoisgregg" its fixed :)
is there any way to do post with iframe i mean without clicking on button etc,
for example i can place iframe on the page and when i open so it well auto add because there are many different different lines and i have to click on the button for every line