Jump to content

Eiolon

Members
  • Posts

    358
  • Joined

  • Last visited

Everything posted by Eiolon

  1. So I have a search form that has multiple fields. All the fields are optional, however, I want users to be able to narrow things down by entering some or all if desired. What I don't know how to do is exclude a field from the search query if nothing is entered. So the form is setup as: Subject: select Topic: text Title: text Year: select Location: text Type: text Current search query and PHP: $subject = $_GET['subject']; $topic = $_GET['topic']; $title = $_GET['title']; $year = $_GET['year']; $location = $_GET['location']; $type = $_GET['type']; $sth = $dbh->prepare(" SELECT * FROM periodic WHERE SUBJECT = :subject AND TOPIC = :topic AND TITLE = :title AND YEAR = :year AND LOCATION = :location AND TYPE = :type "); $sth->bindParam(':subject', $subject); $sth->bindParam(':topic', $topic); $sth->bindParam(':title', $title); $sth->bindParam(':year', $year); $sth->bindParam(':location', $location); $sth->bindParam(':type', $type); $sth->execute(); Obviously the initial query is requiring something in each field with the AND operator and unfortunately, unless the field actually is NULL any field left blank will throw off the results. Thanks for your pointers.
  2. I have submit buttons and they look identical in IE and Chrome but are rendering differently in Firefox. It looks like they are adding padding to it, even though I have a CSS reset and explicitly state the padding. Any ideas on how to force it to look like the IE/Chrome variants? It typically isn't a problem but when the button is next to a text field it isn't uniform with it like the other browsers. .button_submit { margin:0; padding:6px 12px 6px 12px; display:inline-block; border:solid 1px rgba(0,0,0,.05); border-radius:2px; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#FFFFFF; text-align:center; text-decoration:none; vertical-align:baseline; cursor:pointer; }
  3. I apologize if this is not the appropriate forum but it being MySQL related I'll post it here. I am interested in attempting to get certified in MySQL and am looking at the beginning test: http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-870&p_org_id=&lang= Has anyone here taken this exam? I see the exam topics and am wondering how deep and complex it gets or if it's more surface material. Any examples of what to look for? Are questions adaptive? I have no formal training of MySQL but I've been using it daily for the last 5 years so I am just trying to judge if I stand a shot as it is or if I need to do some hard studying / labs. Thanks.
  4. Thanks for your help, I understand now.
  5. I am trying to generate a random 4 character alphanumeric code. For some reason my script is sometimes generating a 3 character code, though most the time it is doing a 4 character. Thanks for your help! <?php function randomCode() { $length = 4; $characters = '2345678ABCDEF'; $code= ''; for ($p = 0; $p < $length; $p++) { $code.= $characters[mt_rand(0, strlen($characters))]; } return $code; } echo randomCode($code); ?>
  6. I guess you could do a couple of approaches. 1. Host the login on your server. Make myproduct.theircompany.com forward to the login page. 2. Host the login on your server, but on myproduct.theircompany.com use an include for the login form. Looks like it is hosted on their server but in reality the form itself is included from your server. 3. Store session information in a database and use a custom session save handler.
  7. Turns out while I had installed Visual C++ Redistributable for Visual Studio 2010 SP1 for Apache, I still had to install Visual C++ Redistributable for Visual Studio 2008 SP1 for PHP. All is well now.
  8. Running: Windows Server 2008 R2 64-bit Apache 2.4.4 32-bit from Apache Lounge PHP 5.4.16 VC9 x86 Apache works fine until I add the following lines at the end of the httpd config file: LoadModule php5_module "c:/php/php5apache2_4.dll" AddHandler application/x-httpd-php .php PHPIniDir "C:/php" The module is located in the path. I have the Microsoft VS2010 Redistributable x86 installed. I have C:\PHP; added to the environmental variables in Windows. Error that occurs when starting the service: Cannot load C:/PHP/php5apache2_4.dll into server: The application has failed to start because its side-by-side configuration is incorrect.
  9. PHP probably has nothing to do with this, but I just want to make sure. I get the hostname of computers in our LAN on many occassions. However, sometimes it is read and displayed differently. I have not been able to determine what causes it. Using code: $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); I will get the hostname displayed as either: JOHNSPC or JOHNSPC.domain.tld It will randomly decide which one to display. I just wanted to make sure there is nothing I can do in PHP configuration to make sure it is consistantly read as one or the other. I know I can make it read only up to the period, which I may end up having to do.
  10. I need to connect to a database that happens to store the users' passwords in plain text. This is simply to authenticate them then the connection is closed. Is there anything that I can do when connecting, besides the usual validation and sanitization, to make it secure? I am thinking about doing SSL if that is possible but I am out of ideas. I do not have the ability to change their policy on plain text passwords.
  11. I am going to guess this is a problem with javascript, because I can use a typical submit button and have it work. I am trying to make it so a text link acts as the submit button and have it delete records that are selected via checkbox. When I click the delete items button it just refreshes the page and removes the check from the box. The record is still there. If I use a submit button it works. I have for the link: <a href="#" onclick="document.forms['delete_items'].submit();" title="Delete Items">Delete Items</a> I have for my form: <form id="delete_items" name="delete_items" method="POST" action=""> <table class="data"> <tr style="background:#F1F1F1;"> <td style="width:20px"></td> <td>Item</td> <td>Owner</td> <td style="width:80px">Received</td> <td style="width:80px">Returned</td> <td style="width:80px">Method</td> </tr> <?php while ($row_returns = $sth_returns->fetch(PDO::FETCH_ASSOC)) { ?> <tr onmouseover="this.bgColor='#EBFAFF';" onmouseout="this.bgColor='#FFFFFF';"> <td><input type="checkbox" name="<?php echo $row_returns['id'] ?>" value="<?php echo $row_returns['id'] ?>" style="border:none;" /></td> <td><?php echo htmlspecialchars($row_returns['item'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo htmlspecialchars($row_returns['owner'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo htmlspecialchars($row_returns['date_received'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo htmlspecialchars($row_returns['date_returned'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo htmlspecialchars($row_returns['method'], ENT_QUOTES, 'UTF-8'); ?></td> </tr> <?php } ?> </table> </form> I have for my PHP script: if ($_POST['id'] ) { foreach($_POST as $id) { $sth_delete_item = $dbh_mysql->prepare(' DELETE FROM returns WHERE id = :id '); $sth_delete_item->bindParam(':id', $id); $sth_delete_item->execute(); header("Location: index.php"); } }
  12. Ah, thanks. I wasn't sure if doing that would make it the same DATETIME of a particular record for all records. EDIT: Thanks for the additional info, mikosiko.
  13. I have an existing MySQL database with the column: date_added set as DATETIME I created a new column called: date_edited set as DATETIME What I would like to do is set the DATETIME found in the date_added column into date_edited column for each record without having to do it individually. Any painless way of doing such a thing? Thanks!
  14. Success! I decided to remove my PC from our work domain to see if any group policies were stopping the scripts from working and all is well now. Now I just need to find out the policy that is preventing javascript from running before I can re-add it to the domain.
  15. That doesn't really make sense though. All the books I see tell you to install a webserver on your computer using WAMP or XAMP and work from there. All the Youtube tutorials I was trying to do clearly show the user using localhost for development. Those tutorials work fine on my personal PC but not my work computer. I just got to work and am going to nuke my PC.
  16. Yeah, that's the strange part. The value is getting passed. The same result from my work PC and my home PC in Firebug.
  17. Alright, definitely looks like the computer has something going on. I just got home and just ran the script using WAMP and no problems. Now, spend time trying to figure this out or just wipe my work PC and start fresh ha ha.
  18. Okay, so that script works for me when I go to the link. If I create the script based on the source your provided and try it locally, it does not give the alert. If I upload that script to my live server, it DOES alert. So something is stopping it from working locally. Either WAMP or security settings of some sort. I have tried 3 major browsers and none of them work locally. It may be worth noting I tried this tutorial and it works on the website, but not locally. It works if I upload it to my live server. http://api.jquery.com/submit/
  19. Thanks for your advice. I have tried it both methods suggested and I am still not getting the alert. I have uploaded it to my live web server and am not getting the alert. Here is my updated code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="jquery/jquery-1.8.2.min.js"></script> </head> <body> <form> <input type="text" id="field" /> <input type="submit" id="submit" value="Submit" /> </form> <script type="text/javascript"> $(document).ready(function(){ $("#submit").click(function() { alert("A working example."); }); }): </script> </body> </html> Sorry, the forums seem to lose all my formatting in code tags now.
  20. I am having problems getting jQuery to work on my computer which is running WAMPserver. Basically I used this code to see if it would alert me when the submit button was clicked. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://localhost/jquery/jquery-1.8.2.min.js"></script> <script type="text/javascript"> $('input#submit').on('click', function() { alert(1); )} </script> </head> <body> <form> <input type="text" id="field" /> <input type="submit" id="submit" value="Submit" /> </form> </body> </html> I get no alert when I click the button. I have tried it in IE9, Firefox 15 and Chrome. Does my web server need to be configured in some manner to allow Ajax to be used? EDIT: also tried moving the script to the end body tag.
  21. Nevermind, I figured it out. Thanks!
  22. It's literally just the height command being used. This is the full CSS and HTML. No other CSS on the page as I create each element on its own page then when I am happy with how it looks I move it over to the real full page. I haven't even gotten there yet. #dataTable { } #dataTable td { height:25px; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> </style> </head> <body> <table id="dataTable"> <tr> <td>Date</td> <td>Name</td> <td>Phone Number</td> </tr> <tr> <td>DATA HERE</td> <td>DATA HERE</td> <td>DATA HERE</td> </tr> </table> </body> </html> EDIT: Figured I would include the doctype and all that jazz just in case.
  23. I have a style applied to a table with td set to height:25px. It looks appropriate in Chrome, IE9, Safari but in Firefox it is about 5px too small. Is there anything that I can apply so that Firefox will keep it consistant with the other browsers? If I increase it by 5px it makes the other browsers be 5px too tall.
×
×
  • 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.