drayarms's Profile User Rating: -----

Reputation: 4 Apprentice
Group:
Active Members
Active Posts:
191 (0.12 per day)
Joined:
18-May 11
Profile Views:
2,435
Last Active:
User is offline Aug 22 2015 04:46 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   drayarms has not set their status

Posts I've Made

  1. In Topic: unable to include css file from external folder

    Posted 22 Aug 2015

    No it's just pure css. No html tags. I'm just going to investigate the error

    That's possible but I wouldn't know. Here's the contents of my .htacess file

    php_value memory_limit 32M
    errorDocument 404 /index.php
    
    
  2. In Topic: unable to include css file from external folder

    Posted 21 Aug 2015

    View Postandrewsw, on 21 August 2015 - 03:02 PM, said:

    What error appears in your browser's console?

    Is the CSS loaded and working for another file/directory?



    Well I checked the error console and lo and behold, here's what I had

    "Resource interpreted as Stylesheet but transferred with MIME type text/html:" This refers to the stylesheet

    View Postmax67412, on 21 August 2015 - 07:25 PM, said:

    Although this might not be preferable or efficient, you could use:
    <link rel="stylesheet" type="text/css"  href="http://mydomain.com/style.css"/>
    



    Okay that worked but why would an absolute path to the url work and not a relative path?
  3. In Topic: How to convert javascript integer into PHP integer?

    Posted 27 Jul 2015

    View PostArtificialSoldier, on 27 July 2015 - 09:00 AM, said:

    I told you why it works, because your browser sees the Javascript code in the string and executes it. That's why the length of the string is off. If you don't believe me, open your browser so you see the query printed with the 1, and then right-click and view the HTML source. You will not see PHP printing a number 1, you will see Javascript code that your browser is executing and printing 1. That's also why there is an extra "space" after the 1 - because you used document.writeln (the space is the line break at the end from writeln).

    In short, when you print $number you are printing Javascript code that your browser is executing, you are not printing the number 1 from PHP.


    Makes sense. Thank you for the explanation. I've abandoned this approach in favor of some other less convoluted approach involving Ajax.
  4. In Topic: How to convert javascript integer into PHP integer?

    Posted 25 Jul 2015

    View PostMartyr2, on 24 July 2015 - 12:16 PM, said:

    Well first you can't do that. Javascript here is client side and PHP is server side. Meaning that your number JS variable is not available at the time that the PHP on page B is being executed. Second of all, let's take a look at this code here...

    $number = "<script>document.writeln(localStorage.getItem('number'));</script>";
    	
    	
    	//And run the query
    
    	$query = "SELECT * FROM table WHERE number = '$number' ";
    
    


    Here $number is a string of JS, nothing else. That JS is not executed or anything so when you put it in the query I am not even sure how you are even getting a number at all. Your query should be reading...

    $query = "SELECT * FROM table WHERE number = '<script>document.writeln(localStorage.getItem('number'));</script>' ";
    
    


    Which is obviously not going to work. PHP can render JS, JS can pass values to other PHP pages via AJAX requests and read in through post parameters, but how you are mixing them here is not making sense. Read my blog about this topic...

    http://www.coderslex...o-php-and-back/

    Are you perhaps leaving out some steps?





    I understand the difference between server and client side scripting. But notice in this case that I'm adding a piece of javascript code to the document on the server side, just as I can any html element, assigning the output of that code to a PHP variable, then sending it to the client. I didn't expect it to work at first, but when I tried it, it seemed to work. How else would I get '1 ' in the var dump? I even tried
    echo $number
    
    just to make sure and sure enough, I got a '1' printed on the page.
  5. In Topic: How to convert javascript integer into PHP integer?

    Posted 25 Jul 2015

    View PostArtificialSoldier, on 24 July 2015 - 12:50 PM, said:

    Quote

    The var_dump yields this:

    string(162) "SELECT * FROM table WHERE number = '1 ' "

    Hmm, that's misleading you. First, notice that it says string(162) - 162 is the length. That query doesn't look like 162 characters, it looks like much less, so why it is claiming the variable is 162 characters long? It's because you are printing the Javascript code and the browser runs it and shows the number 1 there instead.


    Well I had to remove some other table columns and associated values from the WHERE clause in the query because I only wanted to include information relevant to the problem. That's why the var dumb string length does not match what I posted.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

drayarms hasn't added any friends yet.

Comments

drayarms has no profile comments yet. Why not say hello?