Jump to content

imperium2335

Members
  • Posts

    385
  • Joined

  • Last visited

Contact Methods

  • MSN
    tom@tcwhiggins.com

Profile Information

  • Gender
    Female

imperium2335's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. I am trying to create a rewrite rule that will let me keep the following URL clean: <script type="text/javascript" src="http://www.mysite.com/views/Page/js/jsfile1.js"></script> To be: <script type="text/javascript" src="http://www.mysite.com/js/jsfile1.js"></script> When I want to include JS and CSS files in any given view, I call: $this->view->js = array('Page/js/jsfile1.js', 'Page/js/jsfile2.js') ; Where Page would change according to the controller you are currently in. E.g. If I am on www.mysite.com/contact, any JS I load be redirected to: www.mysite.com/views/contact/js/jsfile1.js But in the header of my contact page you would only see: <script type="text/javascript" src="http://www.mysite.com/js/jsfile1.js"></script> How can this be done? Or does someone know of a better way to not expose the system directories such as /views etc in a PHP MVC framework (this is my own mini custom framework BTW)? I hope I'm making sense!
  2. Thanks for your reply. No, I only have one thing called invoiceTable, and that is the abstract one I'm creating in this query, no other tables exist with that name.
  3. Jesus cake, I figured it out. Here is the solution in case it helps anyone else: $imgSrc = $_POST['imagePath'.$_GET['img']] ; $thisX1 = $_POST['image' . $_GET['img'] . 'X1'] ; $thisY1 = $_POST['image' . $_GET['img'] . 'Y1'] ; $thisX2 = $_POST['image' . $_GET['img'] . 'X2'] ; $thisY2 = $_POST['image' . $_GET['img'] . 'Y2'] ; $original = imagecreatefromjpeg($imgSrc) ; list($widthOriginal, $heightOriginal) = getimagesize($imgSrc) ; list($width, $height, $ratio) = imageResize($widthOriginal, $heightOriginal, 204) ; $thumbCanvas = imagecreatetruecolor(150, 150) ; $srcX = round($thisX1/$ratio) ; $srcY = round($thisY1/$ratio) ; $sWidth = $thisX2 - $thisX1 ; $sHeight = $thisY2 - $thisY1 ; imagecopyresampled($thumbCanvas, $original, 0, 0, $srcX, $srcY, 150, 150, $sWidth/$ratio, $sHeight/$ratio) ; imagejpeg($thumbCanvas, '../uploads/thumbnail.jpg') ; echo '<img id="image' . $_GET['img'] . '" src="' . '../uploads/thumbnail.jpg' . '" />' ;
  4. Hi, I have an interface where the user picks an image to upload, it then uploads the original (big) image. That same image then appears but at a reduced size of 150px max height or width, the size is defined in the img tag using height="XX" width ="XX", so it is the same image file, just with its dimensions set in the html. The user then drags a div over the image to crop it. The problem I am having is getting the reference image crop dimensions to translate to the actual full size image. Have attached an image of what the result is. What formula do I need to get it to translate to the bigger image properly? Here is my code: if($_GET['mode'] == 'imageupload') { $imgNumber = $_GET['img'] ; $fileName = strtolower($_FILES["setFile$imgNumber"]['name']) ; $ext = explode('.', $fileName) ; if($ext[1] != 'jpg' && $ext[1] != 'JPG' && $ext[1] != 'jpeg') { echo "<span class='iFOutput'>Can only accept JPG images.<br /><br /> The image you tried to upload was '" . $ext[1] . "'.</span>" ; exit() ; } $tmpName = $_FILES["setFile$imgNumber"]['tmp_name'] ; move_uploaded_file($tmpName, '../uploads/' . $fileName) ; $sizeInfo = getimagesize('../uploads/' . $fileName) ; $resizedArray = imageResize($sizeInfo[0], $sizeInfo[1], 204) ; $finalImageSrc = '../uploads/' . $fileName ; echo '<img id="image' . $imgNumber . '" src="' . $finalImageSrc . '" width="' . $resizedArray[0] . '" height="' . $resizedArray[1] . '" />' ; // SCALED IMAGE FOR CROPPING INTERFACE } elseif($_GET['mode'] == 'imagecrop') { $imgSrc = $_POST['imagePath'.$_GET['img']] ; $thisX1 = $_POST['image' . $_GET['img'] . 'X1'] ; $thisY1 = $_POST['image' . $_GET['img'] . 'Y1'] ; $thisX2 = $_POST['image' . $_GET['img'] . 'X2'] ; $thisY2 = $_POST['image' . $_GET['img'] . 'Y2'] ; $original = imagecreatefromjpeg($imgSrc) ; list($width, $height) = getimagesize($imgSrc) ; if ($width > $height) { $ratio = (150 / $width); } else { $ratio = (150 / $height); } echo $ratio ; $thumbCanvas = imagecreatetruecolor(150, 150) ; $thisX1 = round($thisX1/$ratio) ; $thisY1 = round($thisY1/$ratio) ; imagecopyresampled($thumbCanvas, $original, 0, 0, $thisX1, $thisY1, 150, 150, $width, $height) ; imagejpeg($thumbCanvas, '../uploads/thumbnail.jpg') ; echo '<img id="image' . $_GET['img'] . '" src="' . '../uploads/thumbnail.jpg' . '" />' ; }
  5. Hi, Does anyone know why it won't recognise my abstract table? I get the error " PDO::query() [pdo.query]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'overseer_ims.invoicetable' doesn't exist" SELECT (SELECT SUM(invoiceTable.total) FROM invoiceTable WHERE invoiceTable.jobRef = jobs.id) AS total FROM invoices_out, jobs, invoices_out_reference, enquiries, entity_details, (SELECT jobRef, SUM(invoices_out.net+invoices_out.vat) AS total FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id GROUP BY jobRef) AS invoiceTable WHERE invoices_out_reference.jobRef = jobs.id AND invoices_out_reference.invoiceRef = invoices_out.id AND enquiries.id = jobs.enquiryRef AND invoiceTable.jobRef = jobs.id AND enquiries.entityRef = entity_details.id
  6. Sorry guys my bad, I just realised I didn't put any indexes on my reference table columns...
  7. Hi, I am having a problem with a part of my query: "SELECT SQL_CALC_FOUND_ROWS jobs.id AS jobId, enquiries.id AS profId, users.username, entity_details.name AS entityName, branches.name AS branch, orderNumber, entity_vat_numbers.vatCode, entity_account_numbers.accountNumber, (SELECT symbol FROM parts_trading, currencies WHERE parts_trading.enquiryRef = enquiries.id AND parts_trading.sellingCurrency = currencies.id LIMIT 1) AS symbol, (SELECT SUM(quantity) FROM parts_trading WHERE enquiryRef = enquiries.id) - COALESCE((SELECT SUM(quantity) FROM invoices_out_reference WHERE jobRef = jobs.id), 0) AS differentPartsCount, (SELECT SUM(quantity*sellingNet) FROM parts_trading WHERE parts_trading.enquiryRef = enquiries.id) - COALESCE( (SELECT SUM(invoices_out.net) FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id AND invoices_out_reference.jobRef = jobs.id ) , 0) AS netRemaining, (SELECT SUM(quantity*sellingVat) FROM parts_trading WHERE parts_trading.enquiryRef = enquiries.id) - COALESCE( (SELECT SUM(invoices_out.vat) FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id AND invoices_out_reference.jobRef = jobs.id ) , 0) AS vatRemaining, (SELECT SUM(quantity*(sellingNet+sellingVat)) FROM parts_trading WHERE parts_trading.enquiryRef = enquiries.id) - COALESCE( (SELECT SUM(invoices_out.net+invoices_out.vat) FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id AND invoices_out_reference.jobRef = jobs.id ) , 0) AS totalRemaining FROM jobs, enquiries, users, branches, entity_details LEFT JOIN entity_account_numbers ON entity_details.id = entity_account_numbers.entityRef LEFT JOIN entity_vat_numbers ON entity_details.id = entity_vat_numbers.entityRef WHERE enquiries.traderRef = users.id AND jobs.enquiryRef = enquiries.id AND users.branchRef = branches.id AND (SELECT SUM(quantity) FROM parts_trading WHERE enquiryRef = enquiries.id) - COALESCE((SELECT SUM(quantity) FROM invoices_out_reference WHERE jobRef = jobs.id), 0) > 0 AND enquiries.entityRef = entity_details.id" I know for certain that it is the part: "AND (SELECT SUM(quantity) FROM parts_trading WHERE enquiryRef = enquiries.id) - COALESCE((SELECT SUM(quantity) FROM invoices_out_reference WHERE jobRef = jobs.id), 0) > 0" That is causing the problem. Unfortunately this is a vital part of my query used for not displaying rows that have quantities matching the sum of what is in the other table . Is there are more efficient way to get the same result than that part of the query?
  8. Thanks! That is exactly what I wanted. I guess this is how they fake an AJAX file upload.
  9. Hi, I am trying to create a file uploader by following an online tutorial about AJAX file uploading. Due to the nature of my system, I need to override the the form submit function. That is, instead of submit the form by pressing the typical form submit button, I want to submit the form using my function (which is a button in a jquery ui dialog box). How can I do this? ( I have attached a screenshot) Here is my form for the file upload part in the dialog: <form id="imageList" method="post" enctype="application/x-www-form-urlencoded" target="hiddenUpload"> <input name="firstFile" type="file" /> <iframe id="hiddenUpload" name="hiddenUpload" onload="" style="width:0px;height:0px;border:none;"></iframe> </form>
  10. A simple example of using prepared statements would be: $name = $_POST['userSubmitedData'] . '%' ; include('myDatabaseConnectionData.php') ; $result = $dbh->prepare("SELECT id FROM users WHERE name LIKE ?") ; $result->bindParam(1, $name , PDO::PARAM_STR ; $result->execute() ; while($row = $result->fetch(PDO::FETCH_ASSOC)) { // Do stuff. }
  11. Also, does anyone know why bindParam doesn't work? It's why I used bindValue instead.
  12. Hi, I got tired of typing out the same bindParam etc etc so I came up with the function below. As long as you enter your variables into the array in the same order as your placeholders, it works well. Please let me know your thoughts on how to make it better or perhaps there is a method out there that already exists which makes this function pointless!? function autoBind($SQL, $varsArray, $mode = 'FETCH_ASSOC') { include('dbconnect.php') ; $result = $dbh->prepare($SQL) ; $i = 1 ; foreach($varsArray as $current) { if(is_numeric($current)) { $result->bindValue($i, $current, PDO::PARAM_INT) ; } else // Must be string. { $result->bindValue($i, $current, PDO::PARAM_STR) ; } $i++ ; } $result->execute() ; if($mode == 'FETCH_ASSOC') { $output = $result->fetch(PDO::FETCH_ASSOC) ; } elseif($mode == 'FETCHCOLUMN') { $output = $result->fetchColumn() ; } return $output ; }
×
×
  • 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.