473,409 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

PHP- Javascript Help

Hi,

I am using PHP + Javascript and am storing the username as a session variable in PHP and am able to access it with ease in php, however I when I try to read the session var in jacascript, I am utterly failing.
I read many forms and saw that
var fvalue='<%Session("user")%>';
should work but when I say alert(fvalue)
it echoes the string '<%Session("user")%>';
So please help me out with this query.
May 21 '07 #1
8 1165
Motoma
3,237 Expert 2GB
I have moved this thread to the Javascript forum where I am sure that the experts will be of much more help.
May 21 '07 #2
acoder
16,027 Expert Mod 8TB
If that is valid PHP, then you should not have that problem. Are you sure this is in a PHP file.
May 22 '07 #3
Motoma
3,237 Expert 2GB
Hi,

I am using PHP + Javascript and am storing the username as a session variable in PHP and am able to access it with ease in php, however I when I try to read the session var in jacascript, I am utterly failing.
I read many forms and saw that
var fvalue='<%Session("user")%>';
should work but when I say alert(fvalue)
it echoes the string '<%Session("user")%>';
So please help me out with this query.
After taking another look at this, I think I understand what you were trying to do.
If you are trying to retrieve the value of the session information through PHP, you will need to do something like:
Expand|Select|Wrap|Line Numbers
  1. var fvalue='<?=$_SESSION['user']?>';
  2.  
May 22 '07 #4
If that is valid PHP, then you should not have that problem. Are you sure this is in a PHP file.
This code is in a javascript file not php file.
May 22 '07 #5
Motoma
3,237 Expert 2GB
This code is in a javascript file not php file.
You won't be able to attain anything from the session unless you do it sever-side. The typical way of embedding PHP data objects into javascript is to change the extension from .js to .php and include the PHP portions the way I posted above. You can embed and include it the same way, the only difference is that it will be parsed by PHP before passing it along to the web browser.
May 22 '07 #6
You won't be able to attain anything from the session unless you do it sever-side. The typical way of embedding PHP data objects into javascript is to change the extension from .js to .php and include the PHP portions the way I posted above. You can embed and include it the same way, the only difference is that it will be parsed by PHP before passing it along to the web browser.
Hmmm sounds like a good idea ... let me try it and get back to u thanx.
May 22 '07 #7
acoder
16,027 Expert Mod 8TB
After taking another look at this, I think I understand what you were trying to do.
If you are trying to retrieve the value of the session information through PHP, you will need to do something like:
Expand|Select|Wrap|Line Numbers
  1. var fvalue='<?=$_SESSION['user']?>';
  2.  
That looks more like PHP. The other syntax was probably ASP?
May 23 '07 #8
Motoma
3,237 Expert 2GB
That looks more like PHP. The other syntax was probably ASP?
That is my assumption.
May 23 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: lawrence | last post by:
I haven't been able to reach www.php.net for days. Most of the rest of the web is working for me, though I've bad trouble reaching any English sites. Anyone else having trouble?
5
by: Ad Astra | last post by:
I am completely new to PHP and am finding installation the most difficult part to understand and implement. Could someone please review the rather long missive below and assist me? I have...
43
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs is still a pretty new area to me... (been working...
14
by: saayan | last post by:
Hi, I am using PHP 5.0.1 with Apache 2 on Win XP (SP2). My index.php file has require_once contents.php and also for functions.php. My contents.php file also has a require_once for...
4
by: nandyal | last post by:
All, The following script works as intended in MS-Windows and in other Linux boxes, except on the one that runs php 4.3.10. Sorry for the long post. 1) # uname -a Linux bubba 2.4.20 #5 SMP...
0
by: 356523600 | last post by:
HTML To PHP Converter 4.2.1.8 Free download Get more for less ... HTML To PHP Converter 4.2.1.8 Get more for less! With a new version of HTML To PHP Converter 4, we've dropped the price and given...
8
by: Marcel | last post by:
I have a problem with a PHP page that seems to get executed twice. I am running PHP5 ISAPI on 2003 server. The script is a PHP page with a form. When the form is submitted one record have to...
0
by: tsivaraman | last post by:
I am trying to build php-5.2.1 in RedHat Linux 9. I have installed libxml2-2.6.11,mysql-5.0.33,httpd-2.2.4(apache) successfully.When i do 'make' from the php directory,i get the following...
9
by: mekalai82 | last post by:
i have information.php file that file contain following coding <?php echo phpinfo(); ?> while i calling the URL ("http://localhost/information.php"). i am getting the coding <?php echo...
4
by: mechphisto | last post by:
I'm working on a friend's box, Fedora Core 6. It has PHP 5.1.6. I need to install mcrypt into it, and the only way I can find to do it is from source then recompile PHP. So I did all that, and got...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.