Jump to content

Eiolon

Members
  • Posts

    358
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

Eiolon's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  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!
×
×
  • 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.