Jump to content

elis

Members
  • Posts

    149
  • Joined

  • Last visited

    Never

Everything posted by elis

  1. This should be fairly easy for me to figure out, but every loop I try becomes infinite or just plain fails. Here is the snippet I'm trying to loop: <?php if($stmtx->rowCount() !==0){ $table_row.='<table><td><a href="interview-feedback.php?cid=' . $id . '&jid=' . $job['job_id'] . '&TB_iframe=true&height=315& amp;width=450" class="thickbox">Feedback for'; if($status==1) { $table_row.=' 1st interview'; } elseif($status==2){ $table_row.=' 2nd interview'; } elseif($status==3){ $table_row.=' final interview'; } $table_row.='</a></td><td>'; if($complete==0) { $table_row.='INCOMPLETE-IMAGE-HOLDER'; } else{ $table_row.='<img src="images/checkbox-checked.jpg">'; } $table_row.='</td>'; } I'm trying to loop the entire snippet, and continue echoing table rows, until there are no more rows pulled from MYSQL that match a user's id. Can anybody help?
  2. Colons are used for prepared statements.
  3. I have this PHP snippet: <?php $sql = "SELECT resume_id, resume_filename FROM candidateResumes WHERE candidate_id = :cid"; $stmt2 = $conn->prepare($sql); $stmt2->bindParam(':cid', $id); $stmt2->execute(); $resumes = $stmt2->fetchAll(); $stmt2->closeCursor(); if($resumes) { echo ('available'); } else { echo ('empty return');} ?> But for some reason, it's returning as if nothing exists. I've checked the MYSQL table that it's pulling from and it does exist, so I'm assuming I have an problem in my syntax. edit: ":cid and $id are variables from a $_GET statement. The entire script (not just this snippet) runs from the same $_GET statement and everything else that operates from it works, so I'm almost certain it's not that.)
  4. CREATE PROCEDURE modifyCandidates( IN _fname VARCHAR(30), IN _lname VARCHAR(30), IN _writeup TEXT, IN _resume_text TEXT, IN _notes TEXT, IN _resume_doc MEDIUMBLOB, IN _resume_filetype VARCHAR(30), IN _resume_filename VARCHAR(60), IN _recruiter_id INT, IN _email VARCHAR(80), IN _phone VARCHAR(30), IN _address VARCHAR(200), IN _source_id INT, IN _clarity INT, IN _personability INT, IN _year_began INT ) BEGIN DECLARE lid INT; INSERT INTO candidates_info (fname, lname, recruiter_id, date_created, email, phone, source_id, clarity, personability, year_began) VALUES (_fname, _lname, _recruiter_id, NOW(), _email, _phone, _address, _source_id, _clarity, _personability, _year_began); SELECT LAST_INSERT_ID() INTO lid; INSERT INTO candidates_data (candidate_id, writeup, notes, resume_text) VALUES (lid, _writeup, _notes, _resume_text); IF _resume_doc IS NOT NULL THEN INSERT INTO candidateResumes (candidate_id, resume_doc, resume_filetype, resume_filename) VALUES (lid, _resume_doc, _resume_filetype, _resume_filename); END IF; SELECT lid; END Receives this error from MYSQL: I must be denser than I thought as I've spent the past hour searching for my mistake and I can't say that I see anything wrong.
  5. After using Tiny MCE to input text, the following is displayed: <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 (it continues, however, I figured the first line of CSS is enough) I did a clean install and got the same problem. I have a hunch that a <style> tag is not being started, but I'm not sure which files of Tiny MCE to check in. Could someone point me in the correct direction?
  6. Apparently my crap last-minute code write-up did the trick.
  7. I need to restore a deleted stored procedure. I was trying to edit the procedure and somehow, it got deleted even though I never specified for the procedure to be dropped. Is there anyway to restore this deleted procedure? I checked in the daily backups and there are no backups for stored procedures (at least not any I could locate). I did not write this routine so I'm not entirely sure what it entails and cannot rewrite it (I've tried, it didn't work out too well.)
  8. Here is my full script (it's supposed to email the document after it's been uploaded) <?php /* Test emailing ability */ require_once '../startups.php'; if ( isset($_POST['submit_candidate']) ){ if ( is_uploaded_file($_FILES['resume_doc']['tmp_name']) ){ $resume_doc = fopen($_FILES['resume_doc']['tmp_name'], 'rb'); $resume_filetype = $_FILES['resume_doc']['type']; $resume_filename = $_FILES['resume_doc']['name']; } else { $resume_doc = null; $resume_filetype = null; $resume_filename = null; } if(!empty($resume_doc)){ $ext = end(explode('.',$resume_doc)); if($ext = "doc"){ $type ="doc"; } else $type = "docx"; $data = chunk_split(base64_encode($resume_doc)); $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // The message $message = "Line 1\nLine 2\nLine 3"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); $message .= "--{$mime_boundary}\n" . "Content-Type: $resume_filetype;\n" . " name=\"$resume_filename\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; // Send mail('email@emailplace.com','Test Subject',$message, $headers); } echo "mail sent and $type"; } else { echo "<form id=\"new\" action=\"sendmail.php\" method=\"post\" enctype=\"multipart/form-data\"> <div class=\"field-label\"><label for=\"resume_doc\">Formatted Word Resume</label>:</div> <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1000000\" /> <input id=\"resume_doc\" name=\"resume_doc\" type=\"file\" /> <br> <input type=\"submit\" name=\"submit_candidate\" value=\"Submit\" /> <input type=\"button\" value=\"Reset\"/></form>"; } ?> and I receive this error: The email is sent however the attachment isn't. I'm not familiar with the mail() function at all. Can anyone spot what I've done wrong?
  9. I'm trying to fix an email script that isn't submitting when a .docx file is present. However, the computer I'm working off of doesn't have Microsoft Word installed and my computer at home uses XP (hence, uses .doc files). Would anyone be so kind as to upload a .docx file (with some sort of fake content in it, so I can test whether the upload/email script is working) or point me in the direction where I could find .docx files online? I've tried searching but only come across documentation about .docx files. Also, in regards to the email script: this is the current (snippet) of the email script: <?php if(!empty($resume_doc)){ $mail->AddAttachment($_FILES['resume_doc']['tmp_name'],"$fname$lname.doc","base64",$resume_filetype); } ?> Would anyone know how I'd check whether the document being uploaded is .doc or .docx?
  10. I had a quick and possibly stupid question that I hope someone can help me with. I have a script that is supposed to submit emails with attachments that another programmer wrote, however .docx attachments aren't being mailed out. While looking at the previous programmer's code, I noticed this: <?php if(!empty($resume_doc)){ $mail->AddAttachment($_FILES['resume_doc']['tmp_name'],"$fname$lname.doc","base64",$resume_filetype); } ?> Particularly the snippet: $fname$lname.doc. Could this be the reason why .docx files aren't being mailed out (they are being properly stored in MYSQL)? If so, what changes would I make to add both .doc and .docx attachments to the above snippet?
  11. I have a script that is supposed to display how long somebody has been logged in for. The script is based off of tables that are related to an adjoining site. I.E. if somebody were to visit Google from my site, my site would display, in real time, how long they've been visiting Google for until that person clicks the logout button. The tables are connected to each site that is available for visitation: For example: ID ---- SITE ---- USER --- TIME_OPEN 1 | Google.com | test_user | 2008-09-10 13:08:54 2. | Yahoo.com | new_user | 2008-09-10 12:10:33 etc. This worked perfectly fine until I inserted a new site (in the same format in the above example) and suddenly, it stopped showing how long someone was logged in for. I've checked everything and can't figure out why it's no longer working. When I remove the new site from the table, it works again. Here is the full source code: <?php if(!$session->get('s_isLoggedIn')) { redirect('/index.php', 'http://mysite.com'); } else { ?> <table class="sites" cellpadding="0" cellspacing="0" style="width: 350px; margin-left: 20px;"> <?php $sql = "SELECT *, UNIX_TIMESTAMP(time_opened) AS time FROM siteAccounts ORDER BY site DESC"; global $conn; $conn->open(); $stmt = $conn->prepare($sql); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if(!isset($currentSite) || $row['site'] != $currentSite) { $currentSite = $row['site']; echo '<tr><th><img src="img/' . strtolower($currentSite) . '.gif" alt="' . $currentSite . '" /></th></tr>'; } echo '<tr><td class="site"><div class="userpass">Username: ' . $row['user'] . '<br />Password: ' . $row['pass'] . '</div><div>'; if(is_null($row['inits'])) { // No user logged into this account - show login link switch($currentSite) { case 'Google': // Automatically login to dice by emulating a submittal from their login form echo '<form style="margin-top: 3px;" action="http://googlelink/" method="post" target="_blank" onsubmit="new Ajax.Request(\'save_account.php\', { method: \'get\', onComplete: function(transport) { window.location.reload(); }, parameters: { account_id: ' . $row['account_id'] . ' } });"><input type="hidden" name="USERNAME" value="' . $row['user'] . '" /><input type="hidden" name="PASSWORD" value="' . $row['pass'] . '" /><input type="submit" value="Google" id="login" class="gbutton" /></form>'; break; case 'Yahoo': echo '<form style="margin-top: 3px;" action="http://yahoo.com" method="post" target="_blank" onsubmit="new Ajax.Request(\'save_account.php\', { method: \'get\', onComplete: function(transport) { window.location.reload(); }, parameters: { account_id: ' . $row['account_id'] . ' } });"><input type="submit" value="Visit Yahoo" class="ybutton" /></form>'; break; case 'Final': echo '<form style="margin-top: 3px;" action="http://final.com" method="post" target="_blank" onsubmit="new Ajax.Request(\'save_account.php\', { method: \'get\', onComplete: function(transport) { window.location.reload(); }, parameters: { account_id: ' . $row['account_id'] . ' } });"><input type="submit" value="Visit Final" class="fbutton" /></form>'; break; } } else { // User logged in - show time since login button was clicked $name = $session->get('s_name'); $names = explode(' ', $name); echo '<div style="margin-top: 10px; font-size: 125%;"><a href="save_account.php?logout=true&account_id=' . $row['account_id'] . '"><img src="img/reqlist/delete.png" border="0" alt="Logout" /></a> · <strong>Occupied</strong> · ' . $row['inits'] . ' for <div id="cpcontainer_' . $row['account_id'] . '"> </div>'; ?> <? } ?> <script type="text/javascript"> timer_<?=$row['account_id']?>.settime('<?=date('F j, Y G:i:s',$row['time'])?>'); timer_<?=$row['account_id']?>.oncountup=function(result){ var mycountainer=document.getElementById("cpcontainer_<?=$row['account_id']?>") mycountainer.innerHTML=result['minutes']+" minutes "+result['seconds']+" seconds" } </script> <? } ?> </div> </td> </tr> </table> <? } ?> Note: I changed a couple things to match the table example I provided, just so it's easier to follow. Here are the actual problem areas (or what I suspect are the problem areas): this is the same script as above, I've simply highlighted where I suspect something's gone wrong. <?php case 'Final': echo '<form style="margin-top: 3px;" action="http://final.com" method="post" target="_blank" onsubmit="new Ajax.Request(\'save_account.php\', { method: \'get\', onComplete: function(transport) { window.location.reload(); }, parameters: { account_id: ' . $row['account_id'] . ' } });"><input type="submit" value="Visit Final" class="fbutton" /></form>'; break; ?> This ^^ is the most recent addition to the sites as I explained earlier and <?php $name = $session->get('s_name'); $names = explode(' ', $name); echo '<div style="margin-top: 10px; font-size: 125%;"><a href="save_account.php?logout=true&account_id=' . $row['account_id'] . '"><img src="img/reqlist/delete.png" border="0" alt="Logout" /></a> · <strong>Occupied</strong> · ' . $row['inits'] . ' for <div id="cpcontainer_' . $row['account_id'] . '"> </div>'; ?> <?php } ?> <script type="text/javascript"> timer_<?=$row['account_id']?>.settime('<?=date('F j, Y G:i:s',$row['time'])?>'); timer_<?=$row['account_id']?>.oncountup=function(result){ var mycountainer=document.getElementById("cpcontainer_<?=$row['account_id']?>") mycountainer.innerHTML=result['minutes']+" minutes "+result['seconds']+" seconds" } This should show the time below the site name. Some things I've noticed, when I list the sites in Descending order (where the problematic site shows up last on the page) the countup script works properly for all the other sites, just not the problematic site. When it's listed in ascending order, the problematic site appears first and the countup script doesn't operate for any of the sites. Final note: "<?php" isn't continuously called as it is in the posted snippets, I simply did it so the colors would appear and (hopefully) it'd be easier to follow.
  12. Oh well. I didn't think anyone would be able to fix it. I posted a couple times on those PHP Freelancer websites and they wanted me to pay-no joke-$3,000 for 30 lines of code. If anyone else can figure this conundrum out, please post.
  13. Try this: if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) {echo "this email is invalid"; }) Checks for both the presence of an @ sign, a period, and that no odd characters are present in the email. Replace "$email" for whatever the variable for the email input is.
  14. I feel as if I've tried every resource and can't seem to find a solution to this: http://www.phpfreaks.com/forums/index.php/topic,215072.msg982720.html (used a link to the problem to avoid spamming as I can't seem to edit the original post), if someone could pose a solution that works, I'll gladly fork over the cash. I'm that desperate.
  15. I've created a small upload script to upload files in MYSQL, however I'd like to be able to reprint the files (particularly word documents) in HTML. The programmer who wrote the original script (I'm writing a new one because I can't follow his) got the the above scenario to work properly (with some errors) yet he coded in such a bizarre manner that I can't decipher it nor can I get in touch with original writer. That being said, I know the above is possible I just can't figure out how to go about it. I've tried searching around for the answer, but I must be using the wrong search keys because I can't come up with a solution. If someone could kindly point me in the right direction? So far, the upload script works perfectly, it's the outputting Word Documents in HTML that I'm having trouble with. I know he (the original programmer) used some Javascript and AJAX to achieve the results but those aren't my strong points.
  16. I'm editing a script another programmer wrote to upload more than one document, however, the script is assuming that a previous document has already been uploaded. When that's the case (there's already a previous document uploaded) the script executes correctly. However, when there's no previous document (i.e. it's the first upload) the script won't execute, instead the page just refreshes. I've tried going through the script multiple times to locate the problem myself, however PDOs are not my strong point and its likely I glanced over it. If someone could act as a second pair of eyes and point me in the right direction it would be greatly appreciated. Here is the full upload script: <?php /* * attachment.php: Attach a resume to a candidate */ require_once 'startups.php'; if(! $session->get('s_isLoggedIn')) { redirect('/index.php', $_SERVER['REQUEST_URI']); } if(isset($_POST["attach_doc"])) { $id=$_GET['id']; if (is_uploaded_file($_FILES['resume_doc']['tmp_name'])){ $resume_doc = fopen($_FILES['resume_doc']['tmp_name'], 'rb'); $resume_filetype = $_FILES['resume_doc']['type']; }else { $resume_doc = null; $resume_filetype = null; } $qry = "CALL addAttachment(:resume_doc, :resume_filetype, :resume_filename, :id)"; $conn->open(); $stmt = $conn->prepare($qry); $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $stmt->bindParam(':resume_doc', $resume_doc, PDO::PARAM_LOB); $stmt->bindParam(':resume_filetype', $resume_filetype, PDO::PARAM_STR); $stmt->bindParam(':resume_filename', $_FILES['resume_doc']['name']); $stmt->bindParam(':id', $id, PDO::PARAM_INT); $stmt->execute(); ?> <html> <head> <script> self.parent.tb_remove(); self.parent.location.reload(); </script> </head> </html> <? } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Resume Attchment</title> </head> <body bgcolor="#F2F2E3"> <fieldset> <legend style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px">Please locate the file</legend> <form action="attachment.php?id=<?=$_GET['id']?>" method="post" enctype="multipart/form-data" onsubmit=""> <table> <tr> <td><label style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px">Resume:</label></td><td align="left"><input type="file" size="30" name="resume_doc" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px"/></td> </tr> <tr> <td></td> <td align="left"><input style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px" type="submit" value="Attach Document" onclick="if(forms[0].resume_doc.value==''){alert('Please locate the file'); return false;}" name="attach_doc"/></td> </tr> </table> </form> </fieldset> </body> </html> <? } ?> If anything in the code needs clarifying, please let me know.
  17. I've just started working on a project that someone else started, he used the prepare() and execute() statements, which I have no previous experience/knowledge of since I tend to stick with the old fashion query codes. I'm trying to familiarize myself with this type of coding, so my first question is: are the above statements not compatible with PHP 5.2.6? I've done some of my own searching and have found mixed answers. Some people say it's not compatible, other people say it is. I ask because while trying to test the code on my own computer, I receive the following error: (I believe the computer that's running the actual script I'm working on may have a different PHP version than I, I haven't actually checked yet.) The actual coding that outputs the error is: <?php $db_connection = new mysqli("localhost", "user", "password", "db"); $statement = $db_connection->prepare("SELECT thing FROM testops WHERE id = '2'"); $statement->execute(); ?> (The above code may be incorrect, I'm still learning ???) My second question is: As I've stated before, I have no knowledge of executing queries with the above method. Would anyone happen to know of an idiot, and I mean idiot-proof tutorial of how these work, in the most laymen terms possible? I've used PHP.net's explanation (http://de2.php.net/pdo-prepare), but it successfully managed to go over my head.
  18. I'm an amateur when it comes to Joomla, so please bear with me. I'm trying to select a field from a custom table I made in Mysql through a module page on Joomla. However, I've noticed Joomla's PHP commands for pulling tables is fairly...odd (at least to me) Random bit of unrelated code to express what I'm talking about. $query = "UPDATE #__polls"; $database->setQuery( $query ); However, when I try to set a typical code like mysql_query("SELECT field FROM table") or die(mysql_error()); It isn't working. (I can't duplicate the actual errors right now as I'm away from my home computer) I can only assume it's because of how Joomla's set up to operate. I've spent the past four hours on Joomla's site trying to figure this out and I'm ready to slam my head into the keyboard. I realize that Joomla has designated tables so they appear as "#__table", and have tried searching through the code to find where this is being set but haven't found it yet. Can someone explain what it is I'm not understanding or how to select a custom table through a Joomla module? ???
  19. If you haven't already, you may want to add some sort of security instead of relying solely on $_POST[promocode] I.E. $promocode = mysql_real_escape_string($_POST['promocode']);
  20. I've edited the code since and have changed my concept to something much easier, but still need help. Let's say I have two date-based variables: $updatedon and $lastvalidate What I have in mind is comparing the two dates like: if ($updatedon > $lastvalidate) { //positive handle } else { //negative handle } But I want to add seven additional days to whatever the $lastvalidate field brings. How would I do that?
×
×
  • 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.