473,396 Members | 1,784 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,396 software developers and data experts.

Quotes not appearing after variables

I have this block of code....

while($i <= $count)
{
$final = mysql_fetch_row($result);
$blocknamelist .= "<a style = \"cursor: pointer\" onmouseout =
\"clear_desc()\" ";
$blocknamelist .= "onclick = delete_block(\"$final[1]\",\"$final[2]\")
onmouseover = display_desc(\"$final[2]\") >";
$blocknamelist .= "<font color = \"red\">X</font></a>&nbsp;<br />\n";
$i++;
}

This is the output:

<a style =" cursor: pointer" onmouseout =" clear_desc()" onclick =
delete_block("QL","Quick Links) onmouseover = display_desc("Quick
Links) ><font color =" red">X</font></a>&nbsp;<br />
<a style =" cursor: pointer" onmouseout =" clear_desc()" onclick =
delete_block("AD","Admin Menu) onmouseover = display_desc("Admin Menu)
<font color =" red">X</font></a>&nbsp;<br />


As you can see, around Quick Links the quote sequence never shows up
as well as around Admin Menu. I can't figure this out. I have tried
these sequences:

'text "' . $variable . '" more text';
"text \"". $variable . "\" more text";
<<<EOD Text "$variable" more text EOD;

Among as many other patterns I could think of.

What I don't understand is. If I do this:

$test = '"' . $variable . '"';
it works exactly how I want it to act, as well as the same with every
above pattern I have tried. it is only when I try and get it to print
in the above manner within the javascript function calls that I get a
problem. Do the parenthesis in the string effect it some how? I've
never seen it do this before, so I am bamboozled. Any and all help is
appreciated.
Jul 17 '05 #1
4 2021
Someone must have some ideas, come on now, please?
Jul 17 '05 #2
Well I finally got it today. I tried and still try the single quotes
and it fails saying "Unterminated String Literal". Anyways what I
ended up having to do is just add a single quote around the entire
javascript function call. I am really baffled as to why that code
worked for you though :-\. Anyways here is my revised code.

$blocknamelist .= "<a style = 'cursor: pointer;' onmouseout =
'clear_desc()' ";
$blocknamelist .= "onclick =
'delete_block(\"$final[1]\",\"$final[2]\")' onmouseover =
'display_desc(\"Delete $final[2] Block\")' >";
$blocknamelist .= "<font color = 'red'>X</font></a>&nbsp;\n";

I have no idea why adding those single quotes made any effect on it
displaying the double quotes, it still makes no sense to me and I
would be really intrigued to see an explanation of this. Especially
when a variable can hold the information fine, but as soon as I try to
concantenate<sp?> it messes everything all up. Very strange behavior
indeed. But thank you for your responses.

Josh
Jul 17 '05 #3
Well I finally got it today. I tried and still try the single quotes
and it fails saying "Unterminated String Literal". Anyways what I
ended up having to do is just add a single quote around the entire
javascript function call. I am really baffled as to why that code
worked for you though :-\. Anyways here is my revised code.

$blocknamelist .= "<a style = 'cursor: pointer;' onmouseout =
'clear_desc()' ";
$blocknamelist .= "onclick =
'delete_block(\"$final[1]\",\"$final[2]\")' onmouseover =
'display_desc(\"Delete $final[2] Block\")' >";
$blocknamelist .= "<font color = 'red'>X</font></a>&nbsp;\n";

I have no idea why adding those single quotes made any effect on it
displaying the double quotes, it still makes no sense to me and I
would be really intrigued to see an explanation of this. Especially
when a variable can hold the information fine, but as soon as I try to
concantenate<sp?> it messes everything all up. Very strange behavior
indeed. But thank you for your responses.

Josh
Jul 17 '05 #4
.oO(Josh)
Well I finally got it today. I tried and still try the single quotes
and it fails saying "Unterminated String Literal".
What PHP version? Can you strip it down to a short line of code (as
short as possible) that still shows the error?
I have no idea why adding those single quotes made any effect on it
displaying the double quotes,
Quotes are necessary because onXXX are attributes in HTML, their values
should be single- or double-quoted. But I have no idea how or why this
affects PHP.
it still makes no sense to me and I
would be really intrigued to see an explanation of this. Especially
when a variable can hold the information fine, but as soon as I try to
concantenate<sp?> it messes everything all up.
concatenate

Your (old) code works on my system (PHP 5.0.0 and 4.3.3). And so does
the following:

$blocknamelist = "<a style = 'cursor: pointer;'
onmouseout = 'clear_desc()'
onclick = 'delete_block(\"$final[1]\",\"$final[2]\")'
onmouseover = 'display_desc(\"Delete $final[2] Block\")'<font color = 'red'>X</font></a>&nbsp;\n";


Micha
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
13
by: lawrence | last post by:
A user writes this sentence: "It was the New Urbanist's nightmare of sprawl run amok." They input that and my PHP script hits it with addslashes() and then the sentence gets put in the database....
6
by: Cyrus D. | last post by:
Hi guys, I haven't done that much research on this topic but it seems I can use either the single quotes or the double quotes. SInce I am so used to C(++) I prefer the double quotes and am...
9
by: Dynamo | last post by:
Hi, I am still confused as when to use single or double quotes. This works: echo "<td>" . $row . "</td>"; and this does not
1
by: nurddin19 | last post by:
Hi, I have an Excel file (which is converted to csv by a tool and then uploaded to a MySQL database) and then php is used to display the data on the website. In the Excel file i have text...
9
by: gerben | last post by:
LS, I want to make a content management system. Therefore I have to be able to change the content of my mysql database. I'm writing the content to text boxes in forms, to be able to edit them. ...
5
by: prakashwadhwani | last post by:
Hi Guys ... Sorry I'm a little off topic but didn't know on which NG to post. Just purchased a new HP laptop & was working on some Access project when I realized that certain keys when typed...
1
by: veaux | last post by:
I'm using Access query and have to spit out a text file to load into a 3rd party program. The text file has to include quotes (" ") around certain infomation. The string I have is below. ...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.