Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. One Very Important Thing would be to convert to using some other database interface. The 'mysql' one is deprecated meaning "out of favor, not supported, and gone in the latest version of PHP". So - while trying to solve this you might make the change to use either mysqlI or PDO and save yourself another rewrite down the road. You might also explore how to write your code so that the logic (php) is separated from the presentation (html) to make it easier to read and to maintain and easier for others to follow. Place your html at the end (I put it all in a function) and place php vars in the html where you have dynamic content. Then at the beginning do all your input verifications and data lookups and assembling of the dynamic content into those php vars. Then call the function to display all the content. You will have a MUCH cleaner script that a stranger can more easily walk up to and attempt to understand and help with. I may be strange but 99% of my scripts have just one set of php tags (<?php/?>) in them.
  2. Interesting syntax - perhaps you can explain it to me since I have not seen it used before: $ = $ Highestrow sheet-> getHighestRow (); $ = $ Highestcolumn sheet-> getHighestColumn (); Not the use of variable names with a space after their $ character, but the simple attempt to assign a value to a thing named "$". What does that do?
  3. The "deriding" you mention was me pointing out perhaps a misplaced curly brace. If it isn't misplaced then it certainly means that it is unnecessary. As for the echos. If one puts in echos and doesn't get any output what do you think that means? It means you didn't get to them which means you haven't placed them where you think you should be getting to. Or it means the script is failing so miserably that it isn't running at all. Put an echo at the very top (after the error checking lines) and if it doesn't show then your script has serious problems.
  4. Since your last reply didn't address my questions/points I assume you have found a solution for your problem. Bye!
  5. How about reducing your code size by NOT including the class. Isn't that a module that you can just include so that we don't have to scroll thru it? These lines make no sense: if(isset($_POST['delete'])) unset($_POST['delete']); { (Around line 367) And not being a big class user this makes no sense to me: $update = $BidSet->SaveData($_POST,array("Id")) ->SaveFolder('../uploads/') ->AddFiles('BidIDFile') ->AddFiles('Addend1') ->AddFiles('Addend2') ->AddFiles('Addend3') ->AddFiles('Addend4') ......... ......... ; Is that a valid syntax?> PS - do you realize what a royal pia your code structure is? Nobody is ever going to follow and understand it. Good practice dictates that you separate your html (presentation) code from you logic (php) code to make it easier to read, to decipher, to maintain and then to debug. Lastly - If you can - add some echo statements to show the progress that takes place in this quagmire of code so you can at least get close to where the script fails. I suspect it is a fatal error that is not getting output. Have you checked your error_log file for the folder where this code sits?
  6. It belongs at the beginning of your executing script. Just once is all you need. Please show us the actual code you are using for this. As for the message - you never told us if the message is of your own creation or not.
  7. See my signature for the proper code. To help you track things try putting some echos in places to see where your code is actually going.
  8. Is that error message one of yours or is it coming from php? If it is yours, do you have error checking turned on to perhaps get more info?
  9. Thank you Jacques1 for staying with me while I struggled to see the nose on my face! Apparently when I tried to follow your guidance I used the wrong variable since this time it worked perfectly. Do you have a resource for the syntax of the <img> tag using that data: attribute? Haven't been able to locate one.
  10. $bar_image_png is just one of several names I used in my code. As it stands the bar code maker function produces a result that works just fine in my last post. All I am doing is returning that variable and then trying to output it using your latest suggested solution. I have no 'png' named version - there is no other result. If the var I am using is a GD resource so be it. But it works for the imagepng() call so it must be a resource for it. So - apparently there is no other way to output the barcode image?
  11. What you are showing seems to be right. Could improve it by adding a check of the password in the where clause and not selecting the password as one of your results.
  12. PS - the barcode function clearly does work since this code works: $sample = $_POST['sample']; $bar_image = MakeBarcode($sample); header ('Content-type: image/png'); imagepng($bar_image); imagedestroy($bar_image); exit;
  13. Here is what I am doing since I hate using php tags in code midstream: $sample = $_POST['sample']; $bar_image = MakeBarcode($sample); ob_start(); imagepng($bar_image); $bar_image_png = ob_get_clean(); $bar_image64 = base64_encode($bar_image); Then my html looks like: <img src="data:image/png;base64,$bar_image64" alt="$sample"> Results: Where the img s/b I get the little icon of an undefined(?) image. Also I get this error: Warning: base64_encode() expects parameter 1 to be string, resource given in /home/albany/public_html/homejg/jg/barcode_tester.php on line 74 Where line 74 is the call to base64_encode.
  14. That didn't give me anything at all. No errors; no image. To clarify for those still following: I have created a barcode via a function that someone gave me. The output of that function is meant to be output with the following: imagepng($image) I am returning the $image var from the function and attempting to output it to my web page results but failing to get an image unless it is the only thing on the output page AND I use a header call to set the content-type to image/png. The process is: $bar_image = MakeBarcode($sample); // a function that does indeed make a bar code image ob_start(); imagepng($bar_image); $bar_image_png = ob_get_clean(); Actually I do get one bit of output - the undefined little icon.
  15. Ok - the base64 thing in the img tag is giving me a problem. The barcode image is just that and the basse64 function is expecting a string. What am I doing wrong?
  16. Your post begins with what looks like a conversation you are having with someone else. What are you trying to say to US? Your code is weak. You are collecting error messages but outputting them individually so if you have multiple errors you will see the messages multiple times. Either save the output of the errors until the end or do an exit once you do output a message. Your query looks like it has an error in it with that period in the middle of it. I don't know what else you have a problem with.
  17. The multi part thing was just the first thing I thought I had to try. Seems like it is not necessary. I like the file idea - will have to try that, as well as using an iframe - have never done that. Jacques - what does the base64 encoding do to make the display possible?
  18. Ok - trying to use some new little software I got from a fellow poster. Want to display some html output as well as the image produced by the new code. No Can Do. Did some reading on doing multipart content type headers and here is what I am trying: if ($btn == 'Make Barcode' ) { $sample = $_POST['sample']; $bar_image = MakeBarcode($sample); ?> Content-Type: multipart/mixed; boundary="simple boundary" --simple boundary Content-Type: image/png; <?php imagepng($bar_image); ?> --simple boundary Content-Type: text/html; <br><br> Go Back to tester <a href='barcode_tester.php'>Click here</a> <br> --simple boundary <?php imagedestroy($bar_image); exit(); } This what I am getting: Content-Type: multipart/mixed; boundary="simple boundary" --simple boundary Content-Type: image/png; ‰PNG IHDRc£Ò¯PLTEÿÿÿ¥ÙŸÝIDAT•cøºÚß9?Õ¶õr—ý†Q”µŠ5½Ó7ÕIEND®B`‚ --simple boundary Content-Type: text/html; Go Back to tester Click here --simple boundary I'm hoping that some "header" expert can point out my mistake. OR - tell me I can't do this thing.
  19. 1 - you should immediately remove all of the "MySQL_*' code and begin to use either mysqlI_* functions or PDO functions to access your db. If you read the manual you will see that MySQL has been deprecated and you will soon discover that you appl is broken. 2 - Currently you are passing a query statement that has values in it that don't exist. If you had turned on php error checking you would have seen messages telling you this. 3 - If you need to modify the input as you read it, why use a function at all? Try this: (note the use of the proper tags to break out this code example: (do a pdo connect to the db and select your dbname) // open the input $filename = $_GET['file']; // you should validate this input before using it!!! $openfile = fopen($filename, "r"); // write your query and prepare it $q = "Insert into table (DocumentoSD,Descricao,Cod_Client,Cliente) values(:fld1,:fld2,:fld3,:fld4)"; $qst = $pdo->prepare($q); // loop thru the input and do the inserts while($row = fgetcsv($openfile,2048,";")) { // do any input data modifications here $fld1 = $row[0]; $fld2 = $row[1]; $fld3 = $row[2]; $fld4 = $row[3]; // now assign the modified values to an array $parms = array(':fld1'=>$fld1, ':fld2'=>$fld2, ':fld3'=>$fld3, ':fld4'=>$fld4); if (!$qst->execute($parms)) { (handle an error message on failure) exit(); // ? } } close($openfile); echo "All done loading file"; exit(); The only function I would have here is the one that does my connection and selection - something I created when I started using PDO.
  20. I thought of that originally but then I thought "why would anyone want to return an empty array as a result of a POST value?" and said it must mean something else. IMHO I would just return a False like so many PHP functions do
  21. Your use of bla() inside of the getstuff function is kind of strange. Why not just use bla in your mainline code and eliminate the need for getstuff1()?
  22. What does 'bla' do for you when you already have the POST value in hand? And what is '[]' supposed to represent? Plus your functions are not consistent. You pass in a name simply to use it in POST but then you hardcode a POST[index] in the function. If you are going to pass something to a function, keep your function generalized so that it may be used universally.
  23. You are using something interface (framework?) that I am unfamiliar with. Perhaps post on a forum that can help you with that specific technology? If your code is correctly using it to generate other types of fields, then maybe you need to read the manual to see how other fields need to be done.
  24. Glad we could get you on the right track. Learning how to program is not just copying someone else's hard work. It's about learning which involves reading and understanding and practice. Kind of like everything in this world.
×
×
  • 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.