Jump to content

larry29936

Members
  • Content Count

    115
  • Joined

  • Last visited

Community Reputation

0 Neutral

About larry29936

  • Rank
    Advanced Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I found a solution as follows: <?php if($chk == 0): ?> <div>stuff....</div> <?php else: ?> <div>other stuff...</div> <?php endif; ?>
  2. @gw1500se OK, using your code as follows: $stmt = $pdo->prepare("UPDATE files SET filename = '$srcname', logtime=now() WHERE id = 4"); $stmt->execute() ; $chk=1; } if ($chk == 0) { echo \" <div class="container"> <div class="row" style="color:red"> <br><br><br><br><br><br> <center>Database Update Failed</center> </div> </div>" } else { echo \" <div class="container"> <div class="row"> <br><br><br><br><br><br> <center>Database Updated</center> </div> </div>" } ?> I get the following error on the line with the echo: Parse error: syntax error, unexpected '"' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) in /home/larry/web/test/public_html/update.php on line 141
  3. I'm trying to display an html <div> based on the state of a variable set during php execution . The variable is $chk and is set to either 0 or 1 with 0 meaning failed and 1 meaning pass. Here's the code: if <?php echo "{$chk}";?> == 0 <div class="container"> <div class="row" style="color:red"> <br><br><br><br><br><br> <center>Database Update Failed</center> </div> </div> else <div class="container"> <div class="row"> <br><br><br><br><br><br> <center>Database Updated</center> </div> </div> Both of the <div>'s display after the completion of the php instead of the one based on the $chk variable. I've tried several ways to get the value of $chk but neither print_r nor echo seem to work. $chk is set to 0 at the start of the php execution. Thanks in advance, Larry
  4. I have the following php block that works on an existing bootstrap webpage: <?php $isos = glob('download/*.iso'); $iso = $isos[count($isos) -1]; $isoname = basename($iso); $isodown = "/".$isoname; $md5file = md5_file($iso); $pdfs = glob('download/foxcloneV*.pdf'); $pdf = $pdfs[count($pdfs) -1]; $pdfname = basename($pdf); $debs = glob('download/*.deb'); $deb = $debs[count($debs) - 1]; $debname = basename($deb);; $srcs = glob('download/*.tar.*'); $src = $srcs[count($srcs) - 1]; $srcname = ltrim($src,'download/'); ?> When I try to use it in a non-bootstrap website, it fails with the following errors: Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 104 Warning: md5_file(): Filename cannot be empty in /home/larry/web/test2/public_html/download.php on line 106 Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 109 Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 113 Notice: Undefined offset: -1 in /home/larry/web/test2/public_html/download.php on line 117 Each of these failures is the line after the glob. Is the glob failing or is the syntax wrong for non-bootstrap use? Either way, my thinking is that php should behave the same regardless of what the base model for the website is. Both the bootstrap and non-bootstrap sites are running locally under apache2.4 and php7.2. Can someone provide some insight?
  5. @Barand, it's showing most of my IPV6 ranges as overlapping Showing rows 0 - 499 (49184 total, Query took 2.0331 seconds.)
  6. @Barand, I'm getting a sql error when I run your code: SELECT * -> FROM ( -> SELECT CASE WHEN start <= @xend AND end >= @xstart -> THEN id -> ELSE NULL -> END as found -> , @xstart := start as start -> , @xend := end as end -> FROM ip_lookup -> JOIN (select @xstart := null, @xend := null) init -> WHERE id > 3000000 -> ) search -> WHERE found IS NOT NULL; Here's the error: MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-> FROM ( -> SELECT CASE WHEN start <= @xend AND end >= @xstart ' at line 2 Happens both local and on host server.
  7. @Barand, cycling through 5 million pairs of start and end ip's in the lookup table is a chore. I can't think of a way to automate the check for overlapping or duplicate ranges. Do you have any suggestions?
  8. @Barand, I used the original ip_lookup.csv to populate the ip_lookup table and the start and end ip fields are in dot notation for IPv4 ip's and the IPv6 ip's look correct with the start ip's ending with :: and the end ip's ending with :f or :ff. The problem area for me is the download table. I've emptied the original table and modified it to match yours. I exported the download table from the website and tried to import it into the login_time, address, and filename fields into the modified table but I keep getting the following error: " ERROR 1242 (21000): Subquery returns more than 1 row" when I use the following in mysql shell: LOAD DATA LOCAL INFILE '/home/larry/web/sql/download.csv' INTO TABLE download FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES (id,log_time, address, filename); I get the same error if I try to import via phpMyadmin. It appears to be coming from the trigger: CREATE TRIGGER `ip_address_and_refer` BEFORE INSERT ON `download` FOR EACH ROW BEGIN SET NEW.ip_address = inet6_aton(NEW.address), NEW.refer = (SELECT id FROM lookup i WHERE NEW.ip_address BETWEEN i.start AND i.end ); END Do I need to add a "limit 1" to the trigger?
  9. @gizmola, thanks for getting back to me.
  10. @Barand, before I start I want to be sure about something. In your create table for ip_lookup you have both start and end set as varbinary(16). Will that handle full IPv6 addresses?
  11. @Barand, the ip_lookup table is 5,200,000 rows, around half of them are IPv6 ip's and includes location data. The ip's will have to import into varbinary(40) fields instead of varbinary(16) fields so I can work with them. The download table currently has about 2000 rows. There's nothing I can do about previously entered IPv6 ip's in the download table but there aren't that many, less than 100. I think it will take forever to reconfigure everything and import the data. I have nothing but time but it will be pretty boring to do everything on my local server then have to export everything to my web host as well as modify my php code to handle the changes. I guess I'll be busy for the next few days. Thanks for the help.
  12. I’m trying to create a trigger that does two things, first take an ip that’s in dot notation and run inet_aton on it and put the result in another field. Second, checks a lookup table to identify an ip range that the result of the first action falls into and enters the id of that row in the table. This is on a mysql database on my web host. Here’s what I’ve tried: DELIMITER // CREATE TRIGGER before_ins_download BEFORE INSERT ON download FOR EACH ROW begin set new.ip_address = inet_aton(new.`ADDRESS`), new.refer=(select `id` from `ip_lookup` as i where new.ip_address between i.start and i.end limit 1 ); END; // DELIMITER ; It works without the new.refer part but after I added that it just seems to hang and never gets to the closing DELIMITER; . All ip columns are indexed. Does anyone see a mistake in my code? Thanks for looking.
  13. @Barand, Thanks for taking the time and effort. Like you, I'm not familiar with working with IPv6 ip's. Time for me to do more research. At my age, I've got nothing but time. I think the problem is that I'm not getting the full IPv6 ip so they won't convert.
  14. UPDATE: Emptied table and imported download.csv. Still have problem of "Incorrect string value".
×
×
  • 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.