Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. 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.
  2. 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.
  3. 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?
  4. 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.
  5. 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?
  6. 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.
  7. 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.
  8. 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
  9. 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()?
  10. 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.
  11. 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.
  12. 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.
  13. I just love when people say "it's not working" because it tells us exactly what to look for when trying to hope you. Can you possibly tell us what is happening? Are you just getting a blank screen? Are you getting error messages? Are you getting any meaningful output or results? Have you tried adding some debugging code to echo out values along each step of the process so you can track how far your code gets before things go south? PS - Please use the suggested forum tags when posting code. Wrap your code in the "code" tags which are the words 'php' and '/php' wrapped in square brackets. Like this: $var = 1;
  14. Sounds more like you are new to programming in general as well as user forums. This forum is here to help people with their code - not to just hand out snippets of code to solve your problems. When you decide to settle down and teach yourself some stuff and can give us your attempt at a script, then you can ask for help with it.
  15. It's not a waste. You got very good advice. You have just chose to ignore it in your anger at being told what was wrong with your design. Don't feel bad - we all make mistakes when starting out. Of course your choice is going to cost you money. I'm pretty sure that your choice of developer is going to also agree with what you have been told here. If you pay him/her enough money he just may do what you want. But then when you eventually see the problems with your design, you'll have to pay him/her to correct it.
  16. 1 - I think you have an extra set of quotes around $array in your array_map call. 2 - Why apply "intval" to array elements that are clearly not numeric? 3 - To use the IN operator in SQL I think you need to explicitly list the array elements. Try doing an explode of the array into a string with a comma inserted as in: $items = implode(',',$array); ... ... where id in ($items)
  17. To start with - Jacques is giving you extremely good advice. Ignore it at your own peril. Trusting in a secure login is the same thing that all of the big retailers, banks, credit card companies, etc. have been doing for years and look how they make headlines? Through hackers! So - are you going to trust your very bad design behind a security portal that is most likely weak? Secondly - the design of a page with multiple forms that you then want to automatically consolidate is something pretty sophisticated for a newcomer. I suppose you got that from a trusted source also? HTML5 seems to offer the ability to assign input elements to specific forms with certain attributes but I am not sure how that all works now. (Mainly because I have not needed to do that.) If you used a db to store your info you could probably avoid the multi-form concerns that you have just by saving each text box into its own column in your table. Of course as pointed out to you already you have to be sure to sanitize all of your user input data! PS - Trusting in "other people's code" is something to be avoided. Just because it looks great to you (a newbie?) doesn't mean it's so good. Listen to Jacques. He knows of what he speaks.
  18. Sorry. Won't give you code since that is not the focus of this forum. More importantly (as I have been told previously) it is not a good idea to promote "bad code" here, which your goal is to obtain.
  19. Your logic has several NON-nested if statements. Therefore it will evaluate your first search, then your second, then your third without fail. Also - your use of the ".=" to assign the error messages means they will all accumulate. That explains why you have those messages. Question - you are using a syntax for strpos that is not in the manual. The syntax I see is (string,search_string) yet you are using (string,search_string,search_string). I'm surprised it runs at all.
  20. One thing that would help you and would help us to understand would be to SEPARATE your html form your php. Don't start your php process with a line of html. Do all your "thinking work", make your decisions, build php vars with any dynamic html generated by the conditions and THEN output your html, seeded with php vars where their content needs to go. You'll end up with a script that can be more easily modified and understood. Second - How is this form being submitted? You have no submit button so I can only guess that your onchange event is doing it but you didn't show us that code. PS - why is your form saying it will be POST'ing and yet your php code looks for a GET input? Plus - you don't allow for the user to make a mistake with his mouse since the onchange is going to take off as soon as the user does anything. (Although I don't see another element on your form that would trigger the onchange since you aren't showing anyplace else to go to.) So now - do some alterations to separate the functions of this script (sending out the select code, retrieving the chosen option, doing something with that option, sending out the new results) to help us see what you are doing. Perhaps it will also help you see what is wrong. For one thing it will make it easier to add some debugging code so you can see how your script progresses thru the different stages. And add a submit button!
  21. You have already been told many reasons why you can't or shouldn't do this thing. #1 - if you give them your code you're done. They should send you a thank-note before they take your hard work and change it to suit them. (This would be very generous of you!). Do what others here have said. Sign people up for a free trial and record their individual start date and user id. Be sure to store your main code outside of your webtree so they can't steal it and let them play until their time runs out. Put the entry page in the web tree and get their login creds there. Anything else is just not gonna be good for you.
  22. I think I gave you that solution. Perhaps a little unwieldly, but correct.
×
×
  • 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.