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

problem with spaces



this is the code:
print("change_text(\"english\",\"$myrow[word_english]\")>");

change_text(id,text) is a javascript function that changes some of the
text on the page to something else. $myrow[word_english] returns a
field from an entry in a mySQL database.

this works fine, rendering html like this:
change_text("english","green")>

unless $myrow[word_english] has a space in it, then I get this:
change_text("english","dark blue)>

what am I missing?
Thanks in advance! -jf

Jul 17 '05 #1
11 1658
I noticed that Message-ID:
<11*********************@g14g2000cwa.googlegroups. com> from
jf************@yahoo.com contained the following:
unless $myrow[word_english] has a space in it, then I get this:
change_text("english","dark blue)>

what am I missing?


Dunno, try:

print "change_text(\"english\",\"".$myrow['word_english']."\")>";

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
nope, that gives me the exact same result. thx for trying, tho

Jul 17 '05 #3
> print("change_text(\"english\",\"$myrow[word_english]\")>");
Try this:

echo 'change_text( "english", "' . $myrow[ 'word_english' ] . '" )>';
Or check if $myrow[ 'word_english' ] value contains some special chars
at the end, which may influence print/echo.
Hilarion
Jul 17 '05 #4
(jf************@yahoo.com) decided we needed to hear...
this is the code:
print("change_text(\"english\",\"$myrow[word_english]\")>");

change_text(id,text) is a javascript function that changes some of the
text on the page to something else. $myrow[word_english] returns a
field from an entry in a mySQL database.

this works fine, rendering html like this:
change_text("english","green")>

unless $myrow[word_english] has a space in it, then I get this:
change_text("english","dark blue)>

what am I missing?
Thanks in advance! -jf


Maybe this is a bug in the PHP version you're using?
Your code works exactly as expected for me (PHPEd bundled PHP 4.3.4)
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #5
nope, that's even worse... spaces are really the problem.
Here's the javascript text for the function I'm using, have I messed
something up here?

<script language="JavaScript">
function change_text(id,str) {
document.getElementById(id).innerHTML=str
}
</script>

Jul 17 '05 #6
J. Franchino wrote:
nope, that's even worse...
What do you mean by that?
spaces are really the problem.
That would be very strange.

Here's the javascript text for the function I'm using, have I messed
something up here?

<script language="JavaScript">
function change_text(id,str) {
document.getElementById(id).innerHTML=str
}
</script>


Don't think so. If PHP output is messed up then it has nothing to do
with static (not generated) HTML (including JavaScript).
Try using echoing "var_export" on $myrow and on $myrow['word_english'] before your
"print" statement to check what is stored there and look at the HTML source which gets
generated.
Hilarion
Jul 17 '05 #7
okay, Hilarion, here's what I got (btw, thx again for helping):

$myrow gave me this:
array (
0 => '12',
'ID' => '12',
1 => '',
'word_japanese' => '',
2 => 'kon',
'word_romaji' => 'kon',
3 => 'dark blue',
'word_english' => 'dark blue',
4 => '',
'word_imageFN' => '',
5 => '',
'picture1' => '',
6 => '',
'picture2' => '',
7 => '',
'sound1' => '',
8 => '',
'sound2' => '',
9 => '',
'sound3' => '',
10 => '',
'sound4' => '',
11 => '1',
'step' => '1',
)

$myrow[word_english] gave me this:
'dark blue'

to me this offered no hints... does something look wrong to you?

Jul 17 '05 #8
I've got it down to this, but now it's not php, now I think it's a
javascript problem, but I still don't have it figured out... please
help!
<script language="JavaScript">
function change_text(id,str) {
document.getElementById(id).innerHTML=str
}
</script>

<div onclick=change_text("num1","word word")>click here</div>

Span: <b><span id="num1">num1</span></b>

Jul 17 '05 #9
> I've got it down to this, but now it's not php, now I think it's a
javascript problem, but I still don't have it figured out...

<script language="JavaScript">
function change_text(id,str) {
document.getElementById(id).innerHTML=str
}
</script>

<div onclick=change_text("num1","word word")>click here</div>

This "<div>" lacks quotes around "onclick" attribute value.

Try this:

echo '<div onclick="change_text( \'english\', \'' . $myrow[ 'word_english' ] . '\' )">click here</div>';

should output correct HTML/javascript:

<div onclick="change_text( 'english', 'dark blue' )">click here</div>
or this:

echo '<div onclick=\'change_text( "english", "' . $myrow[ 'word_english' ] . '" )\'>click here</div>';

should output (also correct):

<div onclick='change_text( "english", "dark blue" )'>click here</div>
or this:

echo '<div onclick="change_text( &quot;english&quot;, &quot;' . $myrow[ 'word_english' ] . '&quot; )">click here</div>';

which outputs (also correct):

<div onclick="change_text( &quot;english&quot;, &quot;dark blue&quot; )">click here</div>
You can also split the code to:

$onclick = 'change_text( "english", "' . $myrow[ 'word_english' ] . '" )';
echo '<div onclick="' . htmlspecialchars( $onclick ) . '">click here</div>';

which gives same HTML as one before, but is more readable in PHP.
Hilarion
Jul 17 '05 #10
Thanks for all your help, Hilarion. I've got it working now. I ended
up ditching the Javascript and going with this:

print("<font onClick=\"english.innerHTML='$myrow[word_english]'\">");

Jul 17 '05 #11
> Thanks for all your help, Hilarion. I've got it working now. I ended
up ditching the Javascript and going with this:

print("<font onClick=\"english.innerHTML='$myrow[word_english]'\">");

This still is JavaScript :) but I'm glad you solved the problem.
Hilarion
Jul 17 '05 #12

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

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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.