Jump to content

Leaderboard


Popular Content

Showing most liked content since 02/16/2018 in Posts

  1. 1 point
    Anytime you're checking for input values in POST, GET, or COOKIE you should use isset () to check that they exist before doing any operations with them. This is not new to PHP. My guess is that previously you had warnings turned off. Using empty () also works since it uses isset () internally.
  2. 1 point
    I can not fix this script, because the output is not in sync. I have 3 arrays. 1) present column names. 2) prefix (fixed name). 3) suffix (uniqid value). Can someone explain how exactly I should create a foreach loop in a foreach loop with 3 arrays and fetching the field value from the get_result command as the the value it is related to. This would result in: <---->Present Column Name <-----> New Column Name <---->value1 <--------------------------------> value1_abcd <---->value2 <------------------------------> value2_abcd etc. <?php $prefix_arr = array( 'col_a' , 'col_b' ,'col_c' , 'col_d', 'col_e' , 'col_f' , 'col_g' , ) ; $col2 = uniqid(); $suffix = substr($col2, 5, 11); $servername = "localhost"; $username = "userx"; $password = "pass12345"; $dbname = "test_database"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("SHOW COLUMNS FROM table_xyz"); $stmt->execute(); $res = $stmt->get_result(); $pres_colname = $res; // var_dump($prefix_arr); foreach ($prefix_arr as $los_ele){ $prefix = $los_ele; // var_dump($prefix); // var_dump($suffix); $col_new = $prefix."_".$suffix; //var_dump($col_new); foreach ($pres_colname as $val){ $col = $val['Field']; // var_dump($col); ?> <br><input type="text" value =" <?php echo $col; ?>"><input type="text" value ="<?php echo $col_new;?>"> <?php $stmt = $conn->prepare("ALTER TABLE `table_xyz` CHANGE COLUMN `$col` `$col_new` VARCHAR(30) NOT NULL;"); $stmt->execute(); } } //$stmt->close(); $conn->close(); ?> The complicated thing this time is that I need the exact 'Field' value which is an output of get_result, so I can not fit it in.
  3. 1 point
    OR use array $pr_ar $key in foreach to apply index key ref to the newly created array item each loop $pr_ar = array(0 => 'cola', 1 => 'colb', 2 => 'colc', 3 => 'cold'); $unique = uniqid(); $suf = substr($unique, 0, 11); foreach ($pr_ar as $key => $pre) { $new_col = $pre . $suf; $cna = []; $cna[$key] = $new_col; var_dump($cna); } ?> It will give the correct result from your previous post, but why create another array? just gather the string value on each loop, and use to rewrite column name, if this is to used to change column names? as indicated by another topic.
  4. 1 point
    I wouldn't recommend using this code. First, there's a polyfill to define document.getElementsByClassName if it's not already defined, that's there to support browsers older than IE11. document.getElementsByClassName is supposed to return a list of elements that have a particular class. That's all the result array is used for. That's the list of matching elements that gets returned. The addTracker function is supposed to be a cross-browser way to attach an event, but it's not written correctly. Spot the error: if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.addEventListener) { The get_targeted_links function is going to immediately send a tracking request for all links on the page, it does not wait for them to be clicked. In fact, nothing happens when they are clicked. That's where he sets the source of a new image to the PHP page. The browser will send a request for that URL. That's a rather lazy way of sending data to the server. Ajax communication has been possible since IE5, I'm not sure why he describes setting the src of an image as "genius". About the only thing that will do is only cause 1 tracking request per user because the browser will cache that URL thinking it's supposed to be an image. That "addTracker" function is just supposed to assign an event handler to an element. We already have terminology for that so I'm not sure why he's calling event handlers "trackers". Then, finally, all he's doing is tracking page clicks. That would only be useful if he's trying to track clicks to external websites, otherwise his own web server is already keeping logs of every page the server sends out, and there are plenty of statistics packages to analyze server logs. Then there are things like Google Analytics which will capture the same kind of information and a whole lot more. So I'm not sure how much information he's really gathering that's going to be useful. The save_click function also has a while loop at the end that compares the current timestamp to a variable called then, but he never sets the value of then. I'm not sure what the point of that loop is, but you never want to use infinite loops in Javascript, you'll bring the browser down. There's always a better way to do something than have a while loop keep going until the time changes.
  5. 1 point
    Unless its changed, focus is limited to inputs and anchor elements, so targeting elements other than these is your problem. From https://api.jquery.com/focus/ The focus e vent is sent to an element when it gains focus. This event is implicitly applicable to a limited set of elements, such as form elements (<input>, <select>, etc.) and links (<a href>). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property. An element can gain focus via keyboard commands, such as the Tab key, or by mouse clicks on the element.
  6. 1 point
    Yes. Is there anything in the included file db.php that produces printed output -- say, an echo(), print_r(), or similar such statement? Roddy
  7. 1 point
    Ex 2; https://validator.w3.org/nu/?showsource=yes&doc=http%3A%2F%2Fwww.grammarcaptive.com%2Fpodcast_hostpage.php%3Fhash%3D30a6836a3f7c5fc57751a61098e5c221%26podcast_no%3D21#l452c96 Compared to Ex 1 https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.grammarcaptive.com%2Fpodcast_hostpage.php&showsource=yes Ex 3 https://validator.w3.org/nu/?showsource=yes&doc=https%3A%2F%2Fwww.grammarcaptive.com%2Fpodcast_hostpage.php%3Fhash%3D30a6836a3f7c5fc57751a61098e5c221%26podcast%3D21 Even though they have errors, they don't have misplaced or extra closing elements, which is causing alignment issue because the wrapper only wraps the header and does not wrap sidebar OR footer elements. The wrappers bottom margin causes the misalignment of sidebar.
  8. 1 point
    For some reason with Experiment Two, the pagewrap element is not enclosing the sidebar and footer elements, the border along with bottom margin appears wrapping round the header only, which pushes the unenclosed sidebar down. I think you have a extra misplaced closing div after closing main tag, as when viewing page source, the last div is highlighted in red, indicating there is no relative opening div tag to go with it.
  9. 1 point
    My solution is to use click/touch instead of hover. Keep in mind also that hover doesn't work on mobile devices, the browser doesn't know when you're just pointing at something.
  10. 1 point
    You need to do some debugging. You can't just copy some code and give up when the code doesn't work. Look for solutions. You have one single condition to test for here: if($row['amount'] > 0) { header('Location: http://www.example.com/'); } If it redirects, then the count is greater than zero, if it does not redirect then the count is zero or less. You have to do some debugging to find out why this number is zero or less. To start off, print the number. Since it's not redirecting, my guess is that the number is zero, but you should check to make sure. Once you have verified that the number is actually zero then that's clear evidence that the database table does not have any rows that match your query. Maybe there's something wring with your query. The query has two inputs, $user_name and $password. Print out both their values, then check the database table for yourself using phpMyAdmin or similar software to see if there is a row that contains both of those values. There are two possibilities: The values you passed into the query are wrong or the database actually does not contain that data. I can't tell you why the code is not working, but I've just told you how you can find out.
  11. 1 point
    The main issue is the animation. If you eliminate the animation, you're eliminating the window of time in which the user can move the mouse over to a different element. It's a design flaw to have content that changes the location of elements on mouseover and mouseout events because it makes it difficult for the user to reach elements they want to get to. Whenever anything causes elements to shift around, it's always better to use click events for it so that any rearrangement that occurs was intended by the user.
  12. 1 point
    Insert the following code echo $row['amount']; after the following line of code $row = $cf->fetch(PDO::FETCH_ASSOC); and see if its value is, indeed, greater than zero. For, if it is not, you have not met the condition of the if-statement in which the header() function is located. Roddy
  13. 1 point
    The rowCount() method usually only tells you how many rows were updated or deleted in the most recent query. See details here: http://php.net/manual/en/pdostatement.rowcount.php If you want to check that there were any results, you should use the fetch() method. Since all you're doing is checking that a row exists, it is inefficient to select *, because that's pulling all of the data in the row, which you don't need. Instead you should count the rows. // Count rows where the user exists $ck=$flash->prepare("SELECT COUNT(*) AS `amount` FROM `data` WHERE `user`=:user_name AND `password`=:password "); $ck->bindParam(':user_name',$user_name); $ck->bindParam(':password',$password); $ck->execute(); $row = $cf->fetch(PDO::FETCH_ASSOC); if($row['amount'] > 0) { header('Location: http://www.example.com/'); }
  14. 1 point
    What is $flash? Is that a PDO object?
  15. 1 point
    Eliminate all blank spaces before the header() function is invoked. There should be no blank lines, and no blank spaces after each EOL delimiter. This is, by far, the most common source of a failed header() function. Well, at least in my experience. Roddy
  16. 1 point
    If you have a solution to a common HTML or XHTML problem, you can PM me. Please provide the problem and solution with a reference to the website where you found this (if applicable).HOW DO I Make a Guestbook in HTML? Make a Forum in HTML? Make a Blog in HTML? Send emails from a form in HTML? The short answer is, you can't. Basically, any site where you want the visitor/client/user to be able to interact with something on the website, you need what is called Serverside Technologies, that is a Programming Language that executes commands and processes the input from the visitor/client/user, and a Database of some sort that the Programming Language can use as storage space. Look under "Server Scripting" and ".NET (dotnet)" for some popular Programming Languages. Some more that (as of now) are not covered by w3schools include Cold Fusion (CF) and Java Server Pages (JSP) to name a few. TUTORIALS http://w3schools.com/html/default.asphttp://w3schools.com/xhtml/default.asp NOVICE Incorrect Nesting of ElementsElements in HTML cannot overlap each other. The following is invalid:<strong><em>Incorrect nesting</strong></em>In this example, the B element is intended to contain an I element. To be truly contained within the B element, the I element's end tag must occur before the B element's end tag. The following is valid:<strong><em>Correct nesting</em></strong>Using all lowercase letters in a DOCTYPEIn a DOCTYPE, the formal public identifier--the quoted string that appears after the PUBLIC keyword--is case sensitive. A common error is to use the following:<!doctype html public "-//w3c//dtd html 4.0 transitional//en">Here the formal public identifier (FPI) is all lowercase. The validator does not recognize the document as HTML 4.0 Transitional since the expected FPI for HTML 4.0 Transitional uses different case:<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">Missing a required sub-element of HEADIf you receive the error "Missing a required sub-element of HEAD", check that you have included the TITLE element in the HEAD. The TITLE element is required in all HTML documents.Uppercase letters in XHTML tagsIn XHTML, unlike HTML, element and attribute names must be all lowercase. For example, onMouseOver is an invalid attribute in XHTML, which requires use of onmouseover instead. Either is fine in HTML.Email form to yourselfYou'll need to define the action attribute in your form element. Like so <form method="post" action="mailto:myemail@domain.com">It is recommended to use server-side scripting languages such as asp, php, coldfusion... to handle a form. This way the user which submits your form won't need to have a mailing application on his computer and you have more power over the data that is sent to you.Linking within a documentLinks that link within a document work almost the same way as external links using the <A> tag. However, there is an extra step involved. With these types of links you have to create the link and the target.This is how you link to a specific section in a document.<a href="page.html#section1">section 1</a>When you are linking in the same document where the section is you may remove the url in front of the #.<a href="#section1">section 1</a>Here is how you set the section, this is where the link will go to.<a name="section1"></a> INTERMEDIATE Validation Problems with ASCII CharactersOne of the requirements of XHTML-Strict validation is to code certain characters in ASCII syntax. Below is a list of characters and the ASCII equivalents that must be used to achieve proper validation. & = &< = <> = >...Closing /When coding in XHTML you are required to close all non-closing elements with a / at the end.HTML: <img src="images.jpg" alt="">XHTML: <img src="images.jpg" alt="" />Here is a list of non closing elements: br, hr, img, input, link, meta and script (optional).Attribute MinimizationIncorrect: <textarea readonly>READ-ONLY</textarea>Correct: <textarea readonly="readonly">READ-ONLY</textarea>Same goes for selected, should be selected="selected".Deprecated ElementsOlder HTML tags and attributes that have been superseded by other more functional or flexible alternatives (whether as HTML or as CSS) are declared as deprecated in HTML4 by the W3C - the consortium that sets the HTML standards. Browsers should continue to support deprecated tags and attributes, but eventually these tags are likely to become obsolete and so future support cannot be guaranteed.<applet>, <basefont>, <center>, <dir>, <font>, <isindex>, <menu>, <s>, <strike>, <u> and <xmp>. ADVANCED When to use IDs and ClassesClasses aren't always necessary! If every <p> element is going to have the same style, adding a class to every paragraph is redundant at best.IDs should be unique on a page. Let me repeat that: don't reuse IDs! Remember that ID is an abbreviation for "identifier". Use IDs to target specific, individual elements.Classes are meant to be reused. They work great for things like alternating background colors in table rows. (Give every second row a class="alt-bg", for example.)When to use DIVs and SPANsOverviewThe primary difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own. The <div> tag acts includes a paragraph break, because it is defining a logical division in the document. The <span> tag simply tells the browser to apply the style rules to whatever is within the <span>.DIVThe <div> tag defines logical divisions (defined) in your Web page. It acts a lot like a paragraph tag, but it divides the page up into larger sections.<div> also gives you the chance to define the style of whole sections of HTML. You could define a section of your page as a call out and give that section a different style from the surrounding text.But that's not all it does! The <div> tag gives you the ability to name certain sections of your documents so that you can affect them with style sheets or Dynamic HTML.One thing to keep in mind when using the <div> tag is that it breaks paragraphs. It acts as a paragraph end/beginning, and while you can have paragraphs within a <div> you can't have a <div> inside a paragraph. SPANThe <span> tag has very similar properties to the <div> tag, in that it changes the style of the text it encloses. But without any style attributes, the <span> tag won't change the enclosed items at all.The primary difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own. The <div> tag acts includes a paragraph break, because it is defining a logical division in the document. The <span> tag simply tells the browser to apply the style rules to whatever is within the <span>. GOOD PRACTICE Quoting all attribute valuesExample: <td rowspan=3>Correct syntax: <td rowspan="3">This is required for XHTML.Lowercase tagsExample: <STRONG>Correct syntax: <strong>This is required for XHTML.Validate your codeAlways validate your code. W3C HTML/XHTML Validator REFERENCES http://htmlhelp.com/tools/validator/problems.htmlhttp://www.andybudd.com/archives/2004/08/m...n_css_problems/http://www.blackwidows.co.uk/resources/tut...mon-errors.htmlhttp://w3schools.com/tags/default.asphttp://dhost.info/profmemberone/Pages/deprecated.phphttp://webdesign.about.com/od/htmltags/a/aa011000a.htmmyself!
×