Solved

I'm recieving "missing ) after argument list" using the following code

Posted on 2008-10-28
10
870 Views
Last Modified: 2013-12-13
Why do I get "missing ) after argument list"
I'm using a php script to poputlate the href attribute.
what am I doing wrong?

thanks!
<-PHP script cut ->
echo "<a id='".$cat['projNum']."' class='detaillink' href='javascript:doAJAX(projDetails.php,".$cat['projNum'].",detailUpdate,get,0);'   >".$cat['projNum']." ".$cat['Name']."</a>";
 
<- Results in -> 
<a id='0005024.00' class='detaillink' href='javascript:doAJAX(proDetails.php,0005024.00,detailsUpdate,get,0);' >some project name</a>
 
javascript complains:
ERROR: missing ) after argument
doAJAX(projDetails.php,0005024.00,detailsUpdate,get,0);
error-------------------------^

Open in new window

0
Comment
Question by:shootinstr8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 12

Expert Comment

by:adrian_brooks
ID: 22824894
javascript complains:
ERROR: missing ) after argument
doAJAX(projDetails.php,0005024.00,detailsUpdate,get,0);
error-------------------------^
                                          ^-----because perhaps this should be a string, like this '0005024.00' instead of a float, which it's zeros would have also been truncated as there are no leading zeros in real numbers.
0
 

Author Comment

by:shootinstr8
ID: 22824981
Thanks adrian,
I've tried both. When I put the quotes in I get
Error: Syntax error
doAJAX(projDetails.php,
error----------------------^

It trucates it at the single quote.
0
 
LVL 12

Expert Comment

by:adrian_brooks
ID: 22825052
Try wrapping the projDetails.php in single quotes also. Because my guess is that the doAJAX function is expecting the string of what file to call for the RPC functionality.

So, try changing the projDetails.php to 'projDetails.php'.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:shootinstr8
ID: 22825087
Thanks again adrian,
 When I put the quotes in for the first param I get
Error: Syntax error
doAJAX(
error-----^

It trucates it at the single quote
0
 
LVL 12

Expert Comment

by:adrian_brooks
ID: 22825141
OH!!!
in your HTML...chance all your single quotes to double quotes...that's your problem. :P

Your single quotes are confusing the line terminations...hehehe
0
 
LVL 15

Expert Comment

by:MMDeveloper
ID: 22825157
echo "<a id=\"".$cat['projNum']."\" class=\"detaillink\" href=\"javascript:doAJAX('projDetails.php','".$cat['projNum']."','detailUpdate','get',0);\"   >".$cat['projNum']." ".$cat['Name']."</a>";
0
 
LVL 12

Assisted Solution

by:adrian_brooks
adrian_brooks earned 200 total points
ID: 22825184
In PHP...you can escape double quotes in a string by preceeding the double quote with a backslash.

for instance, in the example below, it uses escaped double quotes.
echo "<a id=\"".$cat['projNum']."\" class=\"detaillink\" href=\"javascript:doAJAX(projDetails.php,".$cat['projNum'].",detailUpdate,get,0);\"   >".$cat['projNum']." ".$cat['Name']."</a>";

Open in new window

0
 
LVL 82

Accepted Solution

by:
hielo earned 300 total points
ID: 22825265
copy and paste this:
echo "<a id='{$cat['projNum']}' class='detaillink' href='javascript:doAJAX(\"projDetails.php\",\"{$cat['projNum']}\",\"detailUpdate\",\"get\",0);'   >{$cat['projNum']} {$cat['Name']}</a>";

Open in new window

0
 

Author Closing Comment

by:shootinstr8
ID: 31510883
Thanks ALL! I new to Javascript/php and i couldn't have figured this out by myself! I'm awarding 200 points to adrian for helping get on track and for spending the time to help me.  However I'm awarding hielo 300 points because his was the final solution I ended up using.  hielo, could you point me where I can learn about the syntax you used? I've never seen the braces in place of escaping quotes before, Or maybe just a quick explanation?
0
 
LVL 82

Expert Comment

by:hielo
ID: 22825601
>> I've never seen the braces in place of escaping quotes before
In php if you have:
$greeting = "hello";

you can do this:
echo $greeting;

OR this:
echo "$greeting";

OR this:
echo "{$greeting}";

Notice that beginning and ending characters are double quotes, not apostrophes.

I used it so that is easier to "maintain", but NOT really necessary. The real "solution" I provided was in the javascript statement. If you notice all but one of the parameters are quoted. That was necessary actually.
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question