473,397 Members | 2,099 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,397 software developers and data experts.

Problem with PHP spaces

118 100+
Hi,

I am getting the problem when i used the php code inside javascript. i,e

Expand|Select|Wrap|Line Numbers
  1. <?
  2. $description=<p><strong>This is Test1</strong></p><p><strong>This is Test2</strong></p>
  3. ?>
  4. <script>
  5. alert('<?=$description?>');
  6. </script>
  7.  
  8.  
Above code works fine and give the alert message when page will loaded.

i have modified that above code like that

Expand|Select|Wrap|Line Numbers
  1. <?
  2. $description=<p><strong>This is Test1</strong></p>
  3. <p><strong>This is Test2</strong></p>
  4. ?>
  5. <script>
  6. alert('<?=$description?>');
  7. </script>
  8.  
  9.  
It didn't worked and didn't give any alert message. Anybody Could please tell the solution to my problem.




Thanks
Swetha
Jul 20 '09 #1
3 1318
Dormilich
8,658 Expert Mod 8TB
@swethak
I'd expected a warning at least (usually strings are enclosed in
' or ")
Jul 20 '09 #2
swethak
118 100+
Hi



Thank you very much for your reply. I have used like this

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $description='<p><strong>This is Test1</strong></p>
  3. <p><strong>This is Test2</strong></p>';
  4. ?>
  5. <script>
  6. alert('<?=$description?>');
  7. </script>
  8.  
in that actually i am getting the description from database 'text' data type . For getting clear idea i mentioned like that.
Have an idea could you please tell the solution.


Thanks
Swetha
Jul 20 '09 #3
dlite922
1,584 Expert 1GB
do you have short tag turned on? if not <?= will not work, do <?php echo ...


Dan
Jul 20 '09 #4

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

Similar topics

3
by: Oggdorf | last post by:
The table names in my database schema have spaces. When the .tab files are created in Visual Studio, the constraint names do not have brackets around them causing a syntax error. Is there a...
1
by: bob | last post by:
I have created a simple Windows service in VB.Net which installs fine using InstallUtil.exe to install it to, for example "c:\test", or "c:\Windows\YellowBanana", but if I install it to "c:\Program...
6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
1
by: Tim | last post by:
I ran into a problem with a script i was playing with to check code indents and need some direction. It seems to depend on if tabsize is set to 4 in editor and spaces and tabs indents are mixed on...
2
by: David | last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll get an answer, so trying here. I'm trying to convert a script to use friendly URLs, I've done this before, but my PHP...
12
by: Vadim Guchenko | last post by:
Hello. I'm using the following code: <html> <head> <style type="text/css"> pre {display: inline;} </style> </head>
5
by: Raj | last post by:
Following is a code to replace blanks in entered string with adequate number of tabs & spacings as required. I've taken the width of tab as 5 characters here. The problem that occurs here is for...
5
by: NoOneCanHelpMe | last post by:
Hello everyone, could someone help me please, I want to print out the frequency of each vowel in the string and I think I will need to use the hash table I already have but im not sure how to do it...
1
by: moveitho | last post by:
Hi, I have the following script on my site but need to implement a select menu into the script as it would make it a lot tidier. This script adds the required amount of fields selected by the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.