Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. You have a loop in which you create a table and show the exact same information 5 times. What do you think your output will be??? While it may be a small misnomer, the mysqli_fetch_array fetches an "array of the fields of one record" of the results. Not an array of all the records. Therefore your loop is processing just one result record at a time. Consequently you have to go thru the loop 6 times(?) to get all the records. Thus it would make sense to only create the table one time - before the loop begins, with the end tag after the loop ends. Of course a quick read of this function in the php manual might have made this immediately clear.
  2. Is there a point here?
  3. I think if you had error checking enabled you would see an error in your function calls. Try it.
  4. your mail statement has an error in it?
  5. When I do an ajax process, I use js to make the call, but it is calling a PHP script which returns a "string". WTH is a 'javascript string'? And (as mentioned by others in this conversation) how is receiving this string any different than pasting it into the code like I'm doing now? Yes I use prepared queries but I don't see your example as being helpful to me here. Thank you for your continued patience too.
  6. Jacques1 - I appreciate your comments but I don't understand what your alternate approach entails. I would love to do this the "right" way and make you satisfied with my code, but I don't know what you mean! Are you possibly suggesting that I actually output a js array from my php code and just assign that value in my script section of my eventual output or to a file that then gets included in my output? Probably not, but that's all I see available.
  7. After all the advice you've been given, you still believe that this a good idea? You have to realize that you are talking about trying to write code that examines an incoming webpage that can change at any time and that your code won't change unless you find out that it happened. How are you going to do that? Plus each website is most likely (definitely?) going to different and you will have to have a different method of reading each of them. This a job that involves flying blind most of the time and you want to recruit people to do it for you? Great if you can do it, but what happens once they have been paid (a lot probably!) and you need those changes I mentioned? You think they'll come back or that you will be able to maintain the code? Doing this for just one website is quite possible - I've done it myself. Doing it for many sites is just a monumental task with tons of pitfalls.
  8. I've got a file with some strings that have both types of quotes in them. And I seem to have managed to get the data, display it in my html, store it in a js array (using a json_encode in php and then simply inserting it into my js) but I cannot seem to pass the string as a parameter form an onclick function call to js. For most strings the addslashes makes it work in the function call. But for those with both sets of quotes it won't work. My console tells me there are "unterminated string constants..". I've experimented with many silly changes but none make it work. Ex. of the strings: What do you mean "It's crooked"? Of course I could remove the contraction and that would probably work, but that would be a hack, would not it?
  9. Is this the ajax implementation? If it is how is it different than what I'm doing? The same php code will produce my data again, it is merely the js that is doing something different, yes? Since I haven't learned JQ in the last 3 hours, I don't understand what you are showing me.
  10. From your last - the data isn't secret, no. But why put it in a div tag? I had it as part in the JS portion of my output at first and only moved it to a div tag at your suggestion and don't know why. So - if I do not use the escape option on my php json_encode call, how do I read the damn stuff in js when it has all those backslashes in it? And for the third time - how would ajax alleviate all of your concerns? Please, please show me.
  11. I understanding your concern, but I am at a loss how this situation is a concern. It is a compendium of data from image files on my site which I have uploaded. Period. What Exactly would I need to do to escape this data? And how (again) would Ajax be a solution? I did put this into a hidden div container, but it still shows up in the source code when viewed in the browser.
  12. Moving ahead here is what I have done. Remember - this data is derived from using glob() on a given path to get image files and then using getimagesize() to get the size and building a php array element for each file found. In my mind - this data is not suspect. in my php I did: $json_imgs = json_encode($ar_imgs,JSON_UNESCAPED_SLASHES); to create my JS input. In my html output I did: $code=<<<heredocs <div style='display:none;'> <script type="text/javascript"> img_data = $json_imgs; </script> </div> heredocs; echo $code; And now I have a js array which can be read by my js function which was my goal. What I don't see is why Jacques1 used a display:none in his example since my results are clearly visible to anyone viewing the source of the web page.
  13. You should really read the manual for the functions you are using. There are many good examples of how they relate to other functions so it will help you construct some good code. 1 - your current code cannot possibly run - Turn On Error Checking at the top of every php script you write while in development mode. error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); 2 - Plan what you want to do - your current process is not in the correct order to do your task. You do a fetch of a query result (with an error that makes the statement non-executable) and THEN you check to see how may rows were returned. Does anything seem backwards here?
  14. Pretty explicit message. Handle it.
  15. Jacques1 - Sorry but I don't read jquery. Just looking at it I don't get how you have taken my php-generated data and turned it into a js array. I know you have lectured me before on security concerns, but I still fail to see how data that I am generating without user input or interference can end up being a security concern for my appl. And yes - ajax is available but what is that going to do for me when all I want to do is load a js array. How does one ajax call to a php script do what I want to do better than my current approach?
  16. Uhhh, not a php question per se here but let me ask you - Just how do you know exactly how a search is conducted on each and every website? Is there some "standard" for web designers to follow when adding a search button to their site that I have not noticed when I browse sites daily? I know when I am trying to find something I have to scan the whole page (or pages) looking for how to do a search on that specific site and I'm using my eyes and intelligence to find it. You are talking about a non-AI appl that will do this for you? Or are these sites all identical and you already know how to engage their search protocol?
  17. Even if the data I am using in this case is simply filenames and values that I have collected from the file system?/ Care to elaborate on what your last means, in code terms?
  18. Did you read my previous post? Did you make any changes from what you read? Did you read the .... manual?
  19. I agree - obviously what is being posted is NOT the actual executed code.
  20. First of all you should NOT do your writing this way. Assuming that your php code is going to build something for you that will then exist inside this html code what you do is this: 1 - in the php section of your script (see?) run some code and assign all of it's pertinent output to a php var. 2 - in the html section of your script (see?) place the php value where this generated output is meant to be. Like this: php code section this code is in my php section - already enclosed in php tags since it IS in the php section. Whatever logic you need to run you do here and simply create a var with the data you get from that code. $myvar = " want to add my php working code here, have tried includes but no joy, "; $myvar .= "it either breaks the dropdown menu or I am not getting the results back from the database,"; $myvar .= "my script works ok, have tested it separately";. (note the .= assignment operators on the last two lines.) html section <!-- this code is NOT in php mode - it is being sent directly to the client --> <h2 class="hidenextdiv"> <a href="#">dropdown menu1</a> </h2> <div class="another dropmenuclass"> <h3>Test</h3> <?php echo $myvar; ?> <h3></h3> <div style="clear: both;">worthless div here</div> </div> That is how you separate html from php for the purposes of simplicity, readability and ease of maintenance. Programmatically it makes much better sense to separate your logic from your presentation which is what this does.
  21. If you don't know anything about coding how can we teach you how to get what you need?
  22. Seem to be having a problem with json_encode. My first time using this. What I have is some php generated filenames that include their relative paths along with some attributes such as extension,width & height. I have made a php array out of these with the filename string as the first level key and the attributes being an array under each of those keys. An example: Array ( [/photos/mainmenu/Chateau_dAgassac] => Array ( => jpg [caption] => txt [w] => 600 [h] => 400 ) [/photos/mainmenu/IMG_1358] => Array ( => jpg [caption] => txt [w] => 600 [h] => 400 ) [/photos/mainmenu/IMG_1367] => Array ( => jpg [caption] => txt [w] => 600 [h] => 400 ) ) I then did a json_encode of this array and assigned it to a JS variable and it looks like I want it to look in my js code when I view the source of the output page. Except for one thing. All the keys (filenames) have a backslash in front of all the forward slashes that are part of the path. This complicates things when I try and take a filepath/name string from my html and use it to grab some attributes for that filename An example of the js array: img_data = { "\/photos\/mainmenu\/Chateau_dAgassac":{"img":"jpg","caption":"txt","w":600,"h":400}, "\/photos\/mainmenu\/IMG_1358":{"img":"jpg","caption":"txt","w":600,"h":400}, "\/photos\/mainmenu\/IMG_1367":{"img":"jpg","caption":"txt","w":600,"h":400} } This is literally how it looks in a view of the source code of my browser page. What's the trick to accessing this js array now when I have a filename (href) in my html <img> tag that obviously no longer matches what I have in my js array?
  23. Turn on error checking at the top of your php code. BTW - you only need to turn on php once until you no longer need it. Turning it on for one line, turning it off , and then turning it on for the next line is just so silly. error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); This will show you your errors, of which I think you have several, hence the blank page.
  24. You "recent" code is well outdated. Those messages are telling you that you are using invalid functions, ie, deprecated. You'll have to remove them. In the case of the magic quotes refs, that has gone away so you can simply remove those calls, which were trying to sanitize your input data,which is no longer necessary (this part anyway) since php no longer sets any quotes automatically on inputs The module names and line numbers will (obviously) help you find the offending syntax/references.
  25. You have two where clauses in your query
×
×
  • 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.