Any help is appreciated
Here's the php code that writes a simple string that can be interpreted as a simple href -
-
$someNameVar = $row["name"];
-
$someEmailVar = $row["email"];
-
$someLikeVar = $row["what_u_liked"];
-
-
addslashes($someNameVar);
-
addslashes($someEmailVar);
-
addslashes($someLikeVar);
-
-
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar."<br><a href=javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."'); style=cursor:pointer;cursor:hand;>Click here</a>";
-
-
No matter what I have tried to do, the browser gives back an error of unterminated string literal.
Thanks in advance
7 1426
PHP is not giving that kind of Errors.Problem is with your JavaScript code,because with some sample values for all these three variables its calling for myresume_dom. -
<script language="JavaScript" type="text/javascript">
-
function myresume_dom(para1,para2,para3)
-
{
-
alert(para1+"\n"+para2+"\n"+para3);
-
}
-
</script>
-
<?php
-
//$someNameVar = $row["name"];
-
$someNameVar = 'someNameVar';
-
//$someEmailVar = $row["email"];
-
$someEmailVar = 'someEmailVar@somewhere.com';
-
//$someLikeVar = $row["what_u_liked"];
-
$someLikeVar = 'someLikeVar';
-
-
addslashes($someNameVar);
-
-
addslashes($someEmailVar);
-
-
addslashes($someLikeVar);
-
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar."<br><a href=javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."'); style=cursor:pointer;cursor:hand;>Click here</a>";
-
?>
-
PHP is not giving that kind of Errors.Problem is with your JavaScript code,because with some sample values for all these three variables its calling for myresume_dom. -
<script language="JavaScript" type="text/javascript">
-
function myresume_dom(para1,para2,para3)
-
{
-
alert(para1+"\n"+para2+"\n"+para3);
-
}
-
</script>
-
<?php
-
//$someNameVar = $row["name"];
-
$someNameVar = 'someNameVar';
-
//$someEmailVar = $row["email"];
-
$someEmailVar = 'someEmailVar@somewhere.com';
-
//$someLikeVar = $row["what_u_liked"];
-
$someLikeVar = 'someLikeVar';
-
-
addslashes($someNameVar);
-
-
addslashes($someEmailVar);
-
-
addslashes($someLikeVar);
-
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar."<br><a href=javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."'); style=cursor:pointer;cursor:hand;>Click here</a>";
-
?>
-
First, thank you for your help.
And you are absolutely correct. I believe the problem is that the value of "$someLikeVar" has spaces within the string. For example, say the value is "AJAX DOM PHP MYSQL" which this is the actual example where I receive the error mentioned above.
So, then if you placed your cursor over the link generated, then it would look something like this in the status bar at the bottom of the browser -- "myresume_dom('Bob','bob@yahoo.com','AJAX"
and that's all it shows -- it doesn't terminate the string literal.
I have tried -
-
addslashes() and htmlentities() before generating the string.
-
-
$someNameVar = $row["name"];
-
$someEmailVar = $row["email"];
-
$someLikeVar = $row["what_u_liked"];
-
-
addslashes($someNameVar);
-
addslashes($someEmailVar);
-
addslashes($someLikeVar);
-
-
htmlentities($someNameVar);
-
htmlentities($someEmailVar);
-
htmlentities($someLikeVar);
-
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar." You chose ".$someLikeVar."<br><a href=javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."'); style=cursor:pointer;cursor:hand;>Click here</a>";
-
-
What's strange is that it inserts the value into the MySql table with the complete string. I even made sure that I was receiving the complete string by doing a select and displaying it properly, as you can see in the code above, but for some reason the spaces between the words of the third variable just will not pass properly.
Thanks once more for your help and any thoughts would be appreciated
PHP is not giving that kind of Errors.Problem is with your JavaScript code,because with some sample values for all these three variables its calling for myresume_dom. -
<script language="JavaScript" type="text/javascript">
-
function myresume_dom(para1,para2,para3)
-
{
-
alert(para1+"\n"+para2+"\n"+para3);
-
}
-
</script>
-
<?php
-
//$someNameVar = $row["name"];
-
$someNameVar = 'someNameVar';
-
//$someEmailVar = $row["email"];
-
$someEmailVar = 'someEmailVar@somewhere.com';
-
//$someLikeVar = $row["what_u_liked"];
-
$someLikeVar = 'someLikeVar';
-
-
addslashes($someNameVar);
-
-
addslashes($someEmailVar);
-
-
addslashes($someLikeVar);
-
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar."<br><a href=javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."'); style=cursor:pointer;cursor:hand;>Click here</a>";
-
?>
-
You were correct. It has nothing to do with the PHP code. It was the spaces in the string that I was trying to pass. -
-
$var = str_replace(" ", "", $someLikeVar);
-
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar." You chose ".$someLikeVar."<br>";
-
echo "<a href=javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$var."');";
-
echo " style=cursor:pointer;cursor:hand;>Click here</a>";
-
-
Once I removed the spaces between the words in the string being passed by the variable, then it sent the information just fine, but why can't I send a string with spaces?
I don't think that I've ever had to do it before, but I can not imagine why this would be an issue when the string is surrounded by single quotes. Shouldn't Javascript be able to interpret this as one complete string?
Should I send the string as an array with the spaces, but how would a php array be sent to js?
You were correct. It has nothing to do with the PHP code. It was the spaces in the string that I was trying to pass.
Once I removed the spaces between the words in the string being passed by the variable, then it sent the information just fine, but why can't I send a string with spaces?
I don't think that I've ever had to do it before, but I can not imagine why this would be an issue when the string is surrounded by single quotes. Shouldn't Javascript be able to interpret this as one complete string?
Should I send the string as an array with the spaces, but how would a php array be sent to js?
No need to Use Arrays here just a simple changes. we'll try to enclose your href value with double quotes.and since you are echoing it through php i have to use the escape ( \") .
And here we go.Try this way. -
<html>
-
<head>
-
<script language="JavaScript" type="text/javascript">
-
function myresume_dom(para1,para2,para3)
-
{
-
alert(para1+"\n"+para2+"\n"+para3);
-
}
-
</script>
-
</head>
-
<body>
-
-
<?php
-
//$someNameVar = $row["name"];
-
$someNameVar = 'some Name Var';
-
//$someEmailVar = $row["email"];
-
$someEmailVar = 'someEmailVar@somewhere.com';
-
//$someLikeVar = $row["what_u_liked"];
-
$someLikeVar = 'some Like Var';
-
addslashes($someNameVar);
-
addslashes($someEmailVar);
-
addslashes($someLikeVar);
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar."<br><a href=\"javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."');\" style=cursor:pointer;cursor:hand;>Click here</a>";?>
-
-
</body>
-
</html>
-
No need to Use Arrays here just a simple changes. we'll try to enclose your href value with double quotes.and since you are echoing it through php i have to use the escape ( \") .
And here we go.Try this way. -
<html>
-
<head>
-
<script language="JavaScript" type="text/javascript">
-
function myresume_dom(para1,para2,para3)
-
{
-
alert(para1+"\n"+para2+"\n"+para3);
-
}
-
</script>
-
</head>
-
<body>
-
-
<?php
-
//$someNameVar = $row["name"];
-
$someNameVar = 'some Name Var';
-
//$someEmailVar = $row["email"];
-
$someEmailVar = 'someEmailVar@somewhere.com';
-
//$someLikeVar = $row["what_u_liked"];
-
$someLikeVar = 'some Like Var';
-
addslashes($someNameVar);
-
addslashes($someEmailVar);
-
addslashes($someLikeVar);
-
echo "Welcome, ".$someNameVar." with the email of ".$someEmailVar."<br><a href=\"javascript:myresume_dom('".$someNameVar."','".$someEmailVar."','".$someLikeVar."');\" style=cursor:pointer;cursor:hand;>Click here</a>";?>
-
-
</body>
-
</html>
-
Hey, it worked -- OK! Explain to me why this worked, because I know that I had to have tried this combination of single and double quotes, without the escape sequence, so why does the escape sequence make such a difference?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: fdsl ysnh |
last post by:
--- python-list-request@python.orgдµÀ:
> Send Python-list mailing list submissions to
> python-list@python.org
>
> To subscribe or unsubscribe via the World Wide Web,
> visit
>...
|
by: DigitalRick |
last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my
guestbook. It had been working fine untill I upgraded to Server 2003 (I am
also running Exchange 2003) all locally. I...
|
by: Gerard |
last post by:
Hello
I have created a windows service to monitor a database, it starts some
checks when a timer elapses. The checks send emails depending on their
findings. My issue is that when I created a...
|
by: Frank |
last post by:
Any suggestions on how I should handle this?
I was asked to convert a small web application that was written in classic
ASP into ASP.NET.
The original site uses some VBScript to interface with...
|
by: scottyman |
last post by:
I can't make this script work properly. I've gone as far as I can with
it and the rest is out of my ability. I can do some html editing but
I'm lost in the Java world. The script at the bottom of...
|
by: Paul Cheetham |
last post by:
Hi,
I am developing an application that needs to store some machine-specific
settings. The application is going to be published on the network in
order to keep the clients on the latest version....
|
by: sufian |
last post by:
I am new to the world of PHP. Below is my simple PHP file "invite.php" with a form having an image send button (I have to use the image send button because it is the requirement, may be this is...
|
by: danfolkes |
last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a
"Server". It works the first time I send the from the Node to Server,
but after that it either errors, or does not do...
|
by: varnie |
last post by:
hell-o !~
i faced weird problem during usage boost::pool_allocator.
after i've changed:
typedef boost::shared_ptr< param > ParamPtr;
typedef std::vector< ParamPtr > ParamPtrVector;
with:
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |