Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Not sure if this is the right place ... but anyway

Asked Modified Viewed 1,009 times
J
janmol
J
janmol 10
...........................
Jan Mølgård
PHP-Fusion, Denmark
Phone: 004528966794
Mail: janmol@wordit.dk
Mail: janm@janm.dk

Testsite version 9: http://php-fusion.dk/fusion_9_test/
  • Veteran Member, joined since
  • Contributed 752 posts on the community forums.
  • Started 256 threads in the forums
  • Started this discussions
asked
Veteran Member

I run this:

$result_users = dbquery("SELECT * FROM ".DB_ORGUSER." ORDER BY mail ASC");
echo "<table width='100%'>\n";
$i = 1;
while ($data_users = dbarray($result_users)) {
   $umail = $data_users['mail'];
   $name = $data_users['name'];
   $ipa = $data_users['ip'];
   $dato = $data_users['dato'];
   if ($kontrol == $umail) {
      echo "<tr><td>TOM</td></tr>";
   }
   if ($kontrol != $umail) {
      echo "<tr><td>$i $umail $ipa</td></tr>";
      $result_indsaet = dbquery("INSERT INTO ".DB_ABO." (rec_id, name, mail, aktiveret, slet, dato, ip)
            VALUES ('','$name', '$umail', '1','0', '$dato', '$ipa')");
      $kontrol = $umail;
      $i++;
}
}
echo "<tr><td>$i</td></tr>";
echo "</table>";


But every time I do it, it repeats the INSERT-statement. Which results in the double amount of records as expected. Can anyone see, what I'm doing wrong??

Runs on a brand new XAMPP-installation.
PHP: 5.6.3
MySQL: 5.6.21
0 replies

3 posts

R
Rimelek
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums
answered
Senior Member

I cannot see any problem in your code, except you should not use empty string for auto increment id, but it is not critical.

It is you whole code or you have some lines around this?
More people had the same problem and usually the reason was an img tag with empty "src" or empty "href" of the favicon (or any other loadable object) , so the file could run again, because that became the url of the image.

According to some developer other reason can be the preloading of pages by webbrowsers. If you update/insert data on GET request, the browser can load it when you do not expect.

I think the first case is more likely.
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

at Line 3. Init your $kontrol = '';

you have undefined index error otherwise.

in line 5, if umail does not exist, dbquery insert will happen again. i suggest do a ternary here so umail will have a value always. if not, statement returns true. if umail is blank, it will fire.

try change $kontrol !== $umail if still breaks.
0 replies
R
Rimelek
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums
answered
Senior Member

If $kontrol is initialized as empty string and $umail in the database can be an empty string, then $kontrol !== $umail will not help.
if (!empty($umail) and ...) {

can help.

But I don't think $umail can be empty in this case, if the table contains users.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 3 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

J
J
janmol 10
...........................
Jan Mølgård
PHP-Fusion, Denmark
Phone: 004528966794
Mail: janmol@wordit.dk
Mail: janm@janm.dk

Testsite version 9: http://php-fusion.dk/fusion_9_test/
  • Veteran Member, joined since
  • Contributed 752 posts on the community forums.
  • Started 256 threads in the forums
  • Started this discussions
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
R
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet