{"id":9401,"date":"2022-11-16T04:33:23","date_gmt":"2022-11-16T04:33:23","guid":{"rendered":"https:\/\/max-drake.cc\/?p=9401"},"modified":"2022-11-17T01:38:28","modified_gmt":"2022-11-17T01:38:28","slug":"re-establish-file-download-links-from-ebooks-to-wordpress-site","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=9401","title":{"rendered":"Re-establish file download links  from eBooks to WordPress site"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Background to issue <\/h4>\n\n\n\n<p>Major stuffup, I&#8217;d got spam comments on website and I deleted about 2\/3 of my post table rows. This lost me all my download links to code files for eBooks I&#8217;d published. <\/p>\n\n\n\n<p>I was foolish in that I didn&#8217;t have a backup of the website (I do now) so I had to fix the problem from scratch. <\/p>\n\n\n\n<p>I quickly unpublished all the relevant eBooks and then had to recreate the links to the correct location on the post table in the websites database. <\/p>\n\n\n\n<p>The process I took to do that is show below. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"excel-extracting-url-from-link\">Excel Extracting URL from Link<\/h3>\n\n\n\n<p>As I had to find all the links in the existing books I ended with the text but had to find the links.<br>\nI was using a spreadsheet to itemise all the links and where they are in the books so having a method to extract the actual URL was quite handy. <\/p>\n\n\n\n<p><iframe data-src=\"https:\/\/www.youtube.com\/embed\/5VECmmdtQKE\" title=\"YouTube video player\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" width=\"560\" height=\"315\" frameborder=\"0\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"some-actions-on-database\">Some actions on database<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"delete-rows-in-mysql-table\">Delete rows in MySQL table<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>This <span class=\"hljs-keyword\">below<\/span> buggered <span class=\"hljs-keyword\">my<\/span> Website <span class=\"hljs-keyword\">as<\/span> I couldn't retrieve <span class=\"hljs-keyword\">the<\/span> data <span class=\"hljs-keyword\">after<\/span> <span class=\"hljs-keyword\">it<\/span> was blown away, best <span class=\"hljs-keyword\">to<\/span> backup whole website <span class=\"hljs-keyword\">and<\/span> database <span class=\"hljs-keyword\">first<\/span>, <span class=\"hljs-keyword\">or<\/span> <span class=\"hljs-keyword\">copy<\/span> table <span class=\"hljs-keyword\">first<\/span> <span class=\"hljs-keyword\">before<\/span> using\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-comment\">---DO NOT USE UNDER ANY CIRCUMSTANCES UNLESS YOU HAVE COPIED TABLE FIRST---<\/span>\n<span class=\"hljs-keyword\">DELETE<\/span> <span class=\"hljs-keyword\">FROM<\/span> Students <span class=\"hljs-keyword\">WHERE<\/span> <span class=\"hljs-keyword\">ID<\/span>=<span class=\"hljs-number\">2<\/span>;\n<\/code><\/pre>\n\n\n\n<p>I&#8217;ve a script for this person posting in my Revit Shortcuts site where I can strip them out of the table with <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">DELETE<\/span> <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts\n<span class=\"hljs-keyword\">WHERE<\/span> post_title <span class=\"hljs-keyword\">like<\/span> <span class=\"hljs-string\">'%Crytorhype%'<\/span>\n<\/code><\/pre>\n\n\n\n<p>So can use that in future without blowing away the database table with all my elements in it.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"stop-auto-increment-on-a-table-and-restart-it\">Stop auto increment on a table and restart it<\/h4>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/44087283\/how-to-drop-auto-increment-from-a-mysql-table\">How to drop auto_increment from a mysql table &#8211; Stack Overflow<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">SET<\/span> FOREIGN_KEY_CHECKS=<span class=\"hljs-number\">0<\/span>;\n<span class=\"hljs-keyword\">alter<\/span> <span class=\"hljs-keyword\">table<\/span> added_object <span class=\"hljs-keyword\">modify<\/span> <span class=\"hljs-keyword\">column<\/span> id_interaction_object <span class=\"hljs-built_in\">int<\/span>(<span class=\"hljs-number\">11<\/span>) <span class=\"hljs-keyword\">not<\/span> <span class=\"hljs-literal\">null<\/span>;\n<span class=\"hljs-keyword\">SET<\/span> FOREIGN_KEY_CHECKS=<span class=\"hljs-number\">1<\/span>;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"insert-into-a-row\">Insert into a Row<\/h4>\n\n\n\n<p>I want to be able to put a non-null entry value to the table at an ID just before I need to put in a Download link, so that, when I go back yo auto increment the next one will be the original download link.<br>\nI&#8217;ll need to do them consecutively, so will need to go through all the books and have all the downloads ready to install in sequence.<br>\nNeed to change first Value for the row\/ID in script below <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">SET<\/span> FOREIGN_KEY_CHECKS=<span class=\"hljs-number\">0<\/span>;\n<span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> wordpress332.wp_postsold2(<span class=\"hljs-keyword\">ID<\/span>, post_title, post_content,post_excerpt,to_ping,pinged,post_content_filtered) <span class=\"hljs-keyword\">VALUES<\/span> (<span class=\"hljs-number\">1024<\/span>, <span class=\"hljs-string\">'dummy'<\/span>,<span class=\"hljs-string\">'1'<\/span>,<span class=\"hljs-string\">'1'<\/span>,<span class=\"hljs-string\">'1'<\/span>,<span class=\"hljs-string\">'1'<\/span>,<span class=\"hljs-string\">'1'<\/span>) ;\n<span class=\"hljs-keyword\">SET<\/span> FOREIGN_KEY_CHECKS=<span class=\"hljs-number\">1<\/span>;\n<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/14838368\/add-a-row-to-a-sql-database-which-has-a-identity-primary-key\">c# &#8211; Add a row to a sql database which has a identity primary key &#8211; Stack Overflow<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"delete-a-table\">Delete a Table<\/h4>\n\n\n\n<p>In SQL use DROP for DELETE for TABLES<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">TABLE<\/span> wordpress332.wp_postsold1;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"copy-a-table\">Copy a table<\/h4>\n\n\n\n<p>First line creates table with same structure as the LIKE one  then following 2 lines copies everything from original to new table<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> wordpress332.wp_postsOld2 <span class=\"hljs-keyword\">LIKE<\/span> wordpress332.wp_postsOld;\n\n<span class=\"hljs-keyword\">INSERT<\/span> wordpress332.wp_postsOld2\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsOld;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"view-what-s-in-a-table\">View what&#8217;s in a table<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"reset-increments-not-realy-it-just-stops-autoincrement-puts-the-row-in-and-then-puts-auto-increment-back-on-so-if-auto-increment-set-at-3551-then-the-next-auto-increent-row-will-be-3552-see-below\">Reset Increments-Not realy, it just stops autoincrement, puts the row in and then puts auto-increment back on, so if auto increment set at 3551 then the next auto increent row will be 3552. -SEE BELOW<\/h4>\n\n\n\n<p>If over time there are holes in Database you may want to get rid of the gaps. The risk is that with items moved from one row to a lesser row number, if there is a another table using the ID Key to point to that row, it won&#8217;t point there anymore.<br>\nDon&#8217;t use the below code unless you 1\/ Backup website &amp; database first, OR 2\/ make a copy of the table before doing it, then testing it afterwards.<br>\n<mark class=\"hltr-red\">Otherwise it could be a disaster as things will not point to where they should and so linkages in DB will be broken<\/mark><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">SET<\/span> @<span class=\"hljs-keyword\">count<\/span> = <span class=\"hljs-number\">0<\/span>;\n<span class=\"hljs-keyword\">UPDATE<\/span> wordpress332.wp_postsOld2 <span class=\"hljs-keyword\">SET<\/span> wordpress332.wp_postsOld2.id = @<span class=\"hljs-keyword\">count<\/span>:= @<span class=\"hljs-keyword\">count<\/span> + <span class=\"hljs-number\">1<\/span>;\n\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> wordpress332.wp_postsOld2 AUTO_INCREMENT = <span class=\"hljs-number\">1<\/span>;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"reset-auto-increments\">Reset Auto Increments<\/h4>\n\n\n\n<p><a href=\"https:\/\/www.tutorialspoint.com\/how-to-change-auto-increment-number-in-mysql\">How to change auto increment number in MySQL?<\/a><br>\nSo this below tells auto increment where to start from. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alter <span class=\"hljs-keyword\">table<\/span> wordpress332.wp_posts <span class=\"hljs-comment\">auto_increment=1020<\/span>;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"rename-a-table\">Rename a table<\/h4>\n\n\n\n<p>First I rename the existing wp_posts table to wp_postsOrig<br>\nThen I rename the modified table wp_postsold1 to  wp_posts  which has the row ID incrementing from Row ID=1000 onwards. This allows me to look to put original download links into exactly the same location <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> wordpress332.wp_posts <span class=\"hljs-keyword\">RENAME<\/span> wordpress332.wp_postsOrig;\n<span class=\"hljs-keyword\">ALTER<\/span> <span class=\"hljs-keyword\">TABLE<\/span> wordpress332.wp_postsold1 <span class=\"hljs-keyword\">RENAME<\/span> wordpress332.wp_posts;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"writing-data-from-one-table-to-another-appending-\">Writing data from one table to another (appending)<\/h4>\n\n\n\n<p>See commentary below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"hljs-keyword\">INSERT<\/span> wordpress332.wp_postsOld1\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsOld2;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"process-to-reorganise-table-post-so-that-it-will-be-compacted-to-before-my-book-download-links-\">Process to reorganise Table &#8220;POST&#8221; so that it will be compacted to before my Book download links.<\/h3>\n\n\n\n<p>1\/ Because I&#8217;d originally deleted from Table &#8220;POSTS&#8221; everything after Row 1000, it started incrementing from after the original table row (pre-Delete) so next row is 3551 , so rows go 999,1000, 3551,3552 etc.<br>\nI added some more links to site and so all of those increment after 3551. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>So I copied the &#8220;Post&#8221; Table twice, &#8220;TPost1&#8221; &amp;  &#8220;TPost2&#8221; <\/li>\n\n\n\n<li>in TPost1 I just deleted everything after Row ID=1000<\/li>\n\n\n\n<li>The reason for this is that there are gaps in the rows between Row ID=1 to Row ID=1000 and I don&#8217;t want to mess up any of the existing pointers there. <\/li>\n\n\n\n<li>in TPost 2 I deleted everything before  Row ID =1001, so these rows start at Row ID=3551 and upwards<\/li>\n\n\n\n<li>I then Reset Increments  with SET @count = 1001; so all new fields instead of starting at  Row ID = 3551 now start at Row ID =1001, and say there were 50 rows then the last row is 1051<\/li>\n\n\n\n<li>Although I&#8217;ve made rows TO Row ID =1051 it still auto increments from Row ID = 3551<\/li>\n\n\n\n<li>So I have to use the <mark class=\"hltr-blue\">Reset auto-increment from-  Row ID =1051<\/mark><\/li>\n\n\n\n<li>So the next item that is added goes to Row ID =1052 which is what I want to happen. <\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"process-to-reorganise-table-post-so-that-it-will-accept-new-download-links-from-correct-row-id\">Process to reorganise Table &#8220;POST&#8221; so that it will accept new Download links from correct Row ID<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now that I have a Post Table that goes up to  Row ID =1052, as long as my links are after  ID =1052 the n I can: <\/li>\n\n\n\n<li>Go to MySQL on Remote Desktop connection and in correct database:<\/li>\n\n\n\n<li>Set Auto-Increment to the row number that the next download link should be from, lets say it its ID = 1070, so I set<br>\n&#8211;\n<pre><code class=\"lang-SQL\">alter <span class=\"hljs-keyword\">table<\/span> wordpress332.wp_posts <span class=\"hljs-comment\">auto_increment=1070<\/span>;\n<\/code><\/pre>\n<\/li>\n\n\n\n<li>Then I can go to the Download Monitor Plugin and create a new Download Link and it should show that Row ID= 1070. <\/li>\n\n\n\n<li>If it doesn&#8217;t, and it shows something like Row ID= 1071.  then you need to go back to MySQL Workbench and delete a couple of rows and try again. <\/li>\n\n\n\n<li>I can get a couple of spam comments come in and mess up the sequence so had to delete those Rows, Re-set the auto increment to the row I wanted, delete the last Download Monitor Plugin Download Link and create a new one. <br><\/li>\n\n\n\n<li>You have established the Download Link to the correct row, so can come back later to add file that will be added at a much later Row ID, but it&#8217;ll have the association with that Download link at the  Row ID= 1070 so it works fine<\/li>\n<\/ul>\n\n\n\n<p>One thing to note, you can just give the new Download Link a Title\/Name and PUBLISH, and come back later and add the download link file that you want.<\/p>\n\n\n\n<p>You have established the Download Link to the correct row, so can come back later to add file that will be added at a much later Row ID, but it&#8217;ll have the association with that Download link at the Row ID= 1070 so it works fine<\/p>\n\n\n\n<p>Its actually faster to set these up like this, then come back and add files later, especially if you have large gaps between book Row Download Links<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n<span class=\"hljs-meta\">### Process to reorganise Table \"POST\" so that it will accept new PAGE LINKS for Email Before Download Forms <\/span>\n- I got caught just creating the download monitor links, <span class=\"hljs-keyword\">then<\/span> a couple didn<span class=\"hljs-comment\">'t work, these generally were for Last chapter items, WHERE I gave the whole script of the book, so if they wanted it all in one file then they could give me their email. <\/span>\n- <span class=\"hljs-keyword\">For<\/span> this I used the Email Before Download Plugin. This takes a FORM Row ID &amp; a Download Link Row ID <span class=\"hljs-keyword\">and<\/span> combine them <span class=\"hljs-keyword\">in<\/span> a shortcode <span class=\"hljs-keyword\">on<\/span> a POST <span class=\"hljs-keyword\">or<\/span> PAGE. So the link <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-keyword\">not<\/span> <span class=\"hljs-keyword\">to<\/span> a Download Link but <span class=\"hljs-keyword\">to<\/span> a specific page <span class=\"hljs-keyword\">or<\/span> post <span class=\"hljs-keyword\">on<\/span> the website (I just used pages <span class=\"hljs-keyword\">for<\/span> this). Therefore the PAGE has <span class=\"hljs-keyword\">to<\/span> be created at a specific row number <span class=\"hljs-keyword\">in<\/span> the <span class=\"hljs-comment\">'POST\" Table. <\/span>\n- <span class=\"hljs-keyword\">As<\/span> I<span class=\"hljs-comment\">'d already created Download Links, which were ERRONEOUS I had to go back and mess with the Database. <\/span>\n<span class=\"hljs-meta\">#### Steps to split &amp; rejoin database to be able to insert a NEW item in in the middle of the table <\/span>\n- This <span class=\"hljs-keyword\">is<\/span> a bit messy but code below, I <span class=\"hljs-keyword\">finally<\/span> figured out how <span class=\"hljs-keyword\">to<\/span> <span class=\"hljs-keyword\">do<\/span> comments <span class=\"hljs-keyword\">for<\/span> SQL\n- I<span class=\"hljs-comment\">'ll step through process after code block<\/span>\n```SQL\n\/* *\/\n-- DROP TABLE wordpress332.wp_posts_bac ; \n\/*\n-- This creates Backup table <span class=\"hljs-keyword\">of<\/span> posts - <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">case<\/span> anything goes wrong\nCREATE TABLE <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> EXISTS wordpress332.wp_posts_bac <span class=\"hljs-keyword\">LIKE<\/span> wordpress332.wp_posts;\n\nINSERT wordpress332.wp_posts_bac\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts;\n\n-- check that posts_bac table <span class=\"hljs-keyword\">is<\/span> same <span class=\"hljs-keyword\">as<\/span> orig posts table\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts_bac ;\n *\/\n\n\/* \n-- Create <span class=\"hljs-keyword\">new<\/span> table <span class=\"hljs-keyword\">for<\/span> low <span class=\"hljs-keyword\">end<\/span> - Will add <span class=\"hljs-keyword\">new<\/span> download later\nCREATE TABLE <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> EXISTS wordpress332.wp_postsx1 <span class=\"hljs-keyword\">LIKE<\/span> wordpress332.wp_posts;\n\nINSERT wordpress332.wp_postsx1\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts;\n-- This deletes all rows above <span class=\"hljs-number\">1940<\/span>\n-- DELETE <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsx1 <span class=\"hljs-keyword\">WHERE<\/span> ID&gt;<span class=\"hljs-number\">1940<\/span>;\n\n\n-- Create <span class=\"hljs-keyword\">new<\/span> table <span class=\"hljs-keyword\">for<\/span> low <span class=\"hljs-keyword\">end<\/span> - Will add <span class=\"hljs-keyword\">new<\/span> download later\nCREATE TABLE <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">NOT<\/span> EXISTS wordpress332.wp_postsx2 <span class=\"hljs-keyword\">LIKE<\/span> wordpress332.wp_posts;\n\nINSERT wordpress332.wp_postsx2\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts;\n*\/\n\n-- DELETE <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsx2 <span class=\"hljs-keyword\">WHERE<\/span> ID&lt;<span class=\"hljs-number\">1953<\/span>;\n\n--  <span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsx1 ;\n--  <span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsx2 ;\n--  <span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsx2 ;\n\n-- Rename posts <span class=\"hljs-keyword\">to<\/span> a <span class=\"hljs-number\">2<\/span>nd backup\n-- ALTER TABLE wordpress332.wp_posts RENAME wordpress332.wp_posts_bac2;\n\n-- Rename postsx1 <span class=\"hljs-keyword\">to<\/span> post table\n-- ALTER TABLE wordpress332.wp_postsx1 RENAME wordpress332.wp_posts;\n\n-- Check the <span class=\"hljs-keyword\">new<\/span> posts table <span class=\"hljs-keyword\">to<\/span> make sure its ready \n-- <span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_posts <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> ID DESC LIMIT <span class=\"hljs-number\">10<\/span>; \n\n--  <span class=\"hljs-keyword\">Set<\/span> <span class=\"hljs-keyword\">Auto<\/span> increment <span class=\"hljs-keyword\">to<\/span> download point \n-- alter table wordpress332.wp_posts auto_increment= <span class=\"hljs-number\">1949<\/span> ;\n\n-- GO <span class=\"hljs-keyword\">DO<\/span> DOWNLOAD <span class=\"hljs-keyword\">and<\/span> put <span class=\"hljs-keyword\">in<\/span> <span class=\"hljs-keyword\">New<\/span> !!!!\n--  Add dowwnload <span class=\"hljs-keyword\">as<\/span> well <span class=\"hljs-keyword\">on<\/span> <span class=\"hljs-keyword\">next<\/span> line \n\n\/* \n-- This should copy the higher numbers across <span class=\"hljs-keyword\">on<\/span> top <span class=\"hljs-keyword\">of<\/span> the other \nINSERT wordpress332.wp_posts\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> wordpress332.wp_postsx2;\n*\/\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>POST table has Row ID =2027 as highest row<\/li>\n\n\n\n<li>You want to insert a new Page in at Row ID = 1703,<\/li>\n\n\n\n<li>there is a gap before this of 2 numbers, sp preceding row number is  Row ID = 1701<\/li>\n\n\n\n<li>  After Row ID = 1703, Row ID = 1704 is active so we do not want to mess with that.<\/li>\n\n\n\n<li> Make a copy of POST table first, so you have a backup in case anything is mogadored<\/li>\n\n\n\n<li>Make 2 further exact copies of the POST table, x1 &amp; x2. <\/li>\n\n\n\n<li>Table x1 you then want to delete all rows <strong>above<\/strong> Row ID = 1701, so this is the Lower table, we will set it up so we can insert the new page in at Row ID = 1703<\/li>\n\n\n\n<li>Table x2 you then want to delete all rows <strong>below<\/strong> Row ID = 1704, so this is the Higher table<\/li>\n\n\n\n<li>We then need to Rename the existing POST table <\/li>\n\n\n\n<li>We then rename Table x1 to be POST table<\/li>\n\n\n\n<li>We then set AUTO-INCREMENT =  1703<\/li>\n\n\n\n<li>We then go to Dashboard on website and ADD a NEW PAGE. <\/li>\n\n\n\n<li>This page should have Row ID = 1703<\/li>\n\n\n\n<li>TEST TO CHECK THIS IS SO. by putting URL to that page into the browser. <\/li>\n\n\n\n<li>We can then use:<br>\nINSERT wordpress332.wp_posts<br>\nSELECT * FROM wordpress332.wp_postsx2;<\/li>\n\n\n\n<li>This adds all of the items in Table x2 and adds them onto the POST table. <\/li>\n\n\n\n<li>We can now create a new FORM for getting name &amp; email address and set that up, it will have a row ID, say Row ID =2028<\/li>\n\n\n\n<li>We then create a new Download link to the file that we want to upload, this will have a download link to a row, say Row ID =2029<\/li>\n\n\n\n<li>We then go back to the new Page we have created and create a short-code block where we will insert the Email Before Download Plugin short-code to put the Form on the Page &amp; When filled out and submitted will return the Download link to the specific file.<br> A long process , but I got there in the end.<br> Next time I need to be more careful in seeing if IT\u2019S A download link or a page that the link is pointing to as splitting the Table to add in a Row then merging the table is time consuming, better to have just added them in in an incremental fashion. <\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">End Comment <\/h3>\n\n\n\n<p>It took 3 days from realising what had happened to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li> finding all the download links <\/li>\n\n\n\n<li>working out a methodology that would work<\/li>\n\n\n\n<li>finding all the files (actually available on the website in sub-directory of uploads folder)<\/li>\n\n\n\n<li>working through managing the database and getting the proper SQL commands to do what was required<\/li>\n\n\n\n<li>Doing the actual re-linking to original link ID <\/li>\n\n\n\n<li>Finding that there were pages for &#8220;Email before upload&#8221; for some files, so <\/li>\n\n\n\n<li>Re-splitting Table to insert new page links instead of Download links <\/li>\n\n\n\n<li>Re-publishing books on Amazon &amp; Draft 2 Digital<\/li>\n\n\n\n<li>Writing this article for reference for the future. <\/li>\n<\/ul>\n\n\n\n<p>That will teach me to make sure I have backups. Still, I did learn something along the way. <\/p>\n\n\n\n<p>Another way to look at it is , 1. I really really stuffed up, BUT 2. I was able to fix the issue. <\/p>\n\n\n\n<p>So I&#8217;m quite pleased with being able to resolve the issue. So if it happens another time I can fix it. But I won&#8217;t need to, as I&#8217;ll have a backup!!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Background to issue Major stuffup, I&#8217;d got spam comments on website and I deleted about 2\/3 of my post table rows. This lost me all my download links to code files for eBooks I&#8217;d published. I was foolish in that I didn&#8217;t have a backup of the website (I do now) so I had to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9402,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36,473,29,27],"tags":[],"class_list":["post-9401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databases","category-ebooks","category-web","category-wordpress"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/11\/2022-11-16-16_30_43-MySQL-Workbench-600x400.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/11\/2022-11-16-16_30_43-MySQL-Workbench-600x600.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9401"}],"version-history":[{"count":5,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9401\/revisions"}],"predecessor-version":[{"id":9409,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9401\/revisions\/9409"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/9402"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}