Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Did you read my previous post? Did you make any changes from what you read? Did you read the .... manual?
  2. I agree - obviously what is being posted is NOT the actual executed code.
  3. 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.
  4. If you don't know anything about coding how can we teach you how to get what you need?
  5. 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?
  6. 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.
  7. 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.
  8. You have two where clauses in your query
  9. The security that 'we' as developers are concerned about is 'hacking of input from the client'. Not from our own processes! So the whole question of yours is pretty well moot. IMHO - Any output from a function should be validated during the process of that function and that function should return the proper result so the caller doesn't have to handle it. A simple check on the result of the function call s/b totally sufficient to handle the continuation of your main stream process. if ( !GetSomeInfo($arg1,$arg2,$msg) if ($showerrors) { echo "Error occurred - cannot continue - message is $msg"; exit(); } where $showerrors is only true during development.
  10. Good luck. You came for help. I don't feel I've helped you and I presume you have left the building. I feel sad. Again - good luck.
  11. Whatever page any login process lands you on can easily be customized if you just have the user id that just logged in. If it's your login page then you can easily pass the user id thru a session var and then use it to customize your 'real' page.
  12. But when you start reading an ini file, you may as well be querying a db.
  13. actually you haven't learned. Yes you wrote some rudimentary php code but it is flawed. Besides the intermingling of html and php code needlessly, you did not read the entire manual page covering setcookie. If you had you would realize that you cannot set a cookie and 5 lines later check for its existence. Cookies are not 'real' until the page has refreshed. And I'm pretty sure you didn't read all the documentation since your cookie is malformed to begin with. And to top it all off the html you are outputting for your image display is also bad.
  14. The longer one looks the simpler the error turns out to be.
  15. Yes that works as long as you are comfortable with the possible exposure of that value. As I said I've never seen DW. A couple friends who have used it though and who are new to this whole environment do use it and in our conversations the concepts they are dealing with are just so foreign to me that we tend to have difficulty communicating. My impression is that DW has a way of arranging things and doesn't let you freely determine where things go and how projects/folders are organized on your site. I'm used to having complete control over my site (and I do use 'control') and not having an IDE tell me where to put things.
  16. As Chocu3r said "From the pseudo code below...". What you wrote is NOT code. You simply echoed the 'pseudo code' he wrote. Do you not know the meaning of 'pseudo'? You really need to learn how to write php. That means reading. And reading some more. Did I mention learning?
  17. My use of the word token was simply to indicate "some piece of data". Perhaps you don't (or shouldn't) use the userid as the identifier, but some other 'code' that you create for each user and maybe store in the db where the login credentials are stored. The token that DW passes may not be the thing in this case, altho I don't know anything about dw other than it makes things tricky for newbies doing their first projects I've been told.
  18. the key to solving this was reading the code with a practiced eye looking closely at it. Programmers are always doing this and sometimes even the best need to walk away and clear their minds in order to see the forest thru the trees.
  19. Your first post did not mention that you did not know how to program. Try to be a little more informative in your next post - of which I'm sure there will be many as you embark on learning how to write PHP scripts.
  20. Thousands of strings? And how do you make sure that they are current? What happens when visitor A arrives and the current set of the strings is read and stored. Every body after that sees the same data. But what about when you must alter some strings - how do the users see that updated info without you destroying the current copy of the settings? Really? "Thousands of strings"? And you don't have a paid consultant working on this design for you?
  21. HUH? I didn't say to dump your db - I said to not use the MySQL_* functions of php.
  22. How are you tracking visitors? With a login process perhaps? You have to know some way of who's who, unless you simply want to track the ip address, which won't be at all accurate. So - you log someone in. If they already existed, you change the background on the next page load. Simple?
  23. I really don't think you want to "store ... in the environment". Between the db and the SESSION array, there is no need to do anything else. By environment I think you mean something like an .ini file. But why? Unless you have the world's worst db connection the speed of a db query and the transfer of any application specific settings to an array in the SESSION array is immediate. A simple check for the array right after your session_start call will tell you if you have to do the query or not. In case you are not familiary here's an example: $_SESSION['appl_vars']['name'] = "My Application Name"; $_SESSION['appl_vars']['setting1'] = 'my setting #1'; $_SESSION['appl_vars']['setting2'] = 'my setting #2'; etc. etc. In each of your scripts you would have this: session_start(); if (!isset($_SESSION['appl_vars'])) { include($my_php_path."GetApplData.php"); GetApplData(); }
  24. You will not be writing 'private user pages'. You will be writing a set page that handles a specific user by getting his id and using it to pull together the 'dynamic' data and then outputs that in a web page containing static things like appl name and button options as well as the php-built divs (?) containing each set of docs that the user owns. One page - many users. "over the next few weeks"? I know you are a noob but this really is not that complex. Get familiar with how to create sql tables and then read up on using pdo as your db interface (do not use MySQL_* functions. Check the manual to see why). Be sure to use prepared queries!! Write your file upload page - a good start actually - and do it safely. Get some opinions after you have it working. Then use the glob() function to take the userid and seek all the files for him/her and create the needed html for each result and then output it all. Do not get in the habit of mixing tons of html with php code. The beauty of php is that you can use code to get those filenames and build a chunk of html into a single php var. Then you simply place that var inside your main html ( function perhaps?) so that when you output all your html (headers, names, backgrounds, etc.) you will also output the contents of that var (or vars). Too many beginners like to mingle html and php results and more html, and repeat. Not good practice and hell on reading and understanding it later. Of course I have the time - I'm retired!
×
×
  • 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.