-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Who mentioned jquery? not me. If you want to update the page in front of the user without refreshing/re-displaying it, you have to use ajax. If you want to change your requirements so that you can take the input, run a php script and then display a page with new data then you don't need ajax or js or even jquery
-
1 - you are using prepared statements so no need to add slashes. 2 - The beauty of prepared statements is you only prepare it once and then run the execute with the specific arguments you have for each query. Move the prepare up before your loop. 3 - I don't understand your content at all, but it appears you have one odd " mark in the string each time. Is that what you intend? Plus - what is [\php] supposed to represent?
-
If you want to run your query and show the results on the same page that your input came from you should look into using an ajax process to trigger a php script and then capture the results and use js to place them on your page with the complete refresh. Sorry - don't have an example to show you here.
-
Further reading of the manual indicates that while the sample header of the function call implies that the domain is not optional, the text below indicates that it may be left out. As for the path, I failed to see that you did include that one. So - ignore my response. As already mentioned above, be sure that no output precedes your call to setcookie AND also realize that you won't see an updated cookie value until the next page load. That means if you set the cookie in your script and want to check it immediately after, you can't. So if you are using user input to set the cookie, use that same input to set a local var to be used during the rest of the script. Do the same when retrieving the cookie value on successive executions.
-
YOu are confusing yourself and me. You start a loop to retrieve each row of your query results, but then you grab the next row into $id & $name. So you have data pieces from two separate rows each time thru this loop. Is that what you want?
-
I'm going to start saying my next in all caps because it needs to be driven home for every php coder. TURN ON PHP ERROR CHECKING! error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); WHEN YOU ARE DEVELOPING YOU NEED THIS! That said: What is $GET???
-
Have a look at the manual re: setcookie. To me it appears you are leaving off 2 parameters that PHP does not default for you.
-
read a book on programming. Every language (almost) has loops, whether they use verbs like 'for', 'foreach' 'do -while', 'repeat - until' or whatever else I've forgotten. There's nothing magical. You have a block of code that you want to run over and over against some kind of data and the loop does it for you. It's just a matter of choosing the right loop for your situation. Some loops check the condition prior to executing the included code, others check it at the end. This is not rocket science so you simply need to spend some time reading and learning instead of crying.
-
Making a program to automatically install PHP frameworks
ginerjm replied to CrimpJiggler's topic in Miscellaneous
Why do you have to repeatedly install these frameworks? -
If you had php error checking turned on you probably would have seen an error re: your use of the mail() function. Go read the syntax of this and use it correctly.
-
Can you give us a more complete view of your code? Pieces are hard to follow. Also - you really should consider separating your php logic from your presentation code. Create vars in your php code and then output your html with the vars included rather than turn on php mode to do something (that should have already been done) and turn off php mode.
-
FPDF is really not that hard. Try to design your document in terms of the rows and columns instead of absolute coordinates, except where you want to do something like a logo in a corner or something like that. Picture your line items as a set of columns. When you call Cell for each data item, specify the width of that column regardless of the size of the actual data being output. Of course you need to consider the data size when you choose the column width. Do not use SetX for every output after you have done this - simply let fpdf handle the positioning and only set the 'ln' parm to '1' when you are done with a line. Think of designing a spreadsheet. What I do is set up some php vars for each column size: ( I use inches - you seem to be using mm) $lnht = .2; $col1 = 1.5; $col2 = .5; $col3 = 1.5; ... ... Then my output lines look like: $pdf->Cell($col1,$lnht,$col1_value,0,0,'L'); $pdf->Cell($col2,$lnht,$col2_value,0,0,'L'); $pdf->Cell($col3,$lnht,$col3_value,0,1,'L'); Note the last Cell call triggers a new line with the '1' value.I only use setx, sety for special documents layout. For straight up forms with simple rows and columns this works great for me. Keep playing - it'll come to you.
-
What does your loop do the FIRST time thru since $data has not been defined yet? Even if it doesn't completely fail, why do you want to run thru all that code before you have read a row from your file yet? Wouldn't this form of the do/while concept work better: while ($data = fgetcsv($handle)) { (do your stuff) } PS - you should use ' ' on your indices in associative arrays.
-
What is it that you don't understand? You say you have a problem with loops, but what is it?
-
how to strip everything between key phrase and ending tag
ginerjm replied to Anandlall12's topic in PHP Coding Help
How about reading them and finding out? -
how to strip everything between key phrase and ending tag
ginerjm replied to Anandlall12's topic in PHP Coding Help
You're not following forum rules on posting code? -
Actually I am concerned about the input since I don't see a form tag nor a submit button. So just how do you even know that your data is arriving at your php point? I also agree with everything the Maxdd says. Nor do I see any imput for 'student_id'. Nor do I see anywhere that your message could be produced. Nor do I understand why you do a 'die' followed by an attempt to re-direct to yourself if the date update fails (which won't work).
-
It appears that you have one set of values which work and the second set is empty which causes the query to fail. Don't know what value1 and value2 are. What are you referring to by "first loop"? Can't you simply echo this stuff instead of logging it to make it a bit easier to read?
-
As Psycho said - you are doing the bind correctly. So: How about doing this to your code: foreach($obj as $assocArray) { $id = $assocArray['id']; $name = $assocArray['name']; echo "id is $id name is $name<br>"; if (!$stmt->execute()) // execute the query echo "Execute failed to run"; } And see what happens as you loop thru your data.Note I threw in a check for a failure on the execute. One should do this always,perhaps adding an output of the error message.
-
can we see how you changed your code to accomplish this? Kind of silly to just post some output and ask us to debug that...
-
You buried a php tag inside the heredocs. I'm curious how that works. Try putting an echo statement right after line 324 to see if you are getting to that point when the script is run the FIRST time (when it has to display the screen for the first time). PS - since you have buried all of my code inside a much larger script, try moving my error checking up to the beginning of your bigger script to catch any and all errors.
-
Don't you have to bind after you have assigned the values?