razvypp Posted April 6, 2010 Share Posted April 6, 2010 this works $ico = "1"; ?><? print "<a href='javascript:void(0);' onClick='zz($ico,1,1,1,1,1)' >"; ?> <? print"<img src='$row2[icon]' /></a>"; but this doesn't $ico =$row2['icon']; ?><? print "<a href='javascript:void(0);' onClick='zz($ico,1,1,1,1,1)' >"; ?> <? print"<img src='$row2[icon]' /></a>"; any one know how to solve it ? Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/ Share on other sites More sharing options...
Psycho Posted April 6, 2010 Share Posted April 6, 2010 Doesn't work how? What is the value of "$row2['icon']" and what does the resulting code look like? Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037795 Share on other sites More sharing options...
razvypp Posted April 6, 2010 Author Share Posted April 6, 2010 it doesn't work as in if $ico= any char character it doesn't work ex: $ico="1"; WORKS ex: $ico="s"; doesn't work the $row2['icon']="blabla/asdasa/blabla"; this is the function function zz(lpri,lbuy,id,name,price,desc){ var pop1="<form action=\"shop_f.php\" method=\"post\"><table width=\"200\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#282828\"><tr><td><div align=\"center\"><img src=\"$row2[icon]"; var pop2=".jpg\" alt=\""; var pop3="\" width=\"199\" height=\"136\"></div></td></tr><tr><td class=\"fromadmin-2\">"; var pop4=": $<span class=\"celula-alb-mic\">"; var pop5="</span><br>"; var pop6="<br>Nr:<input name=\"number\" class=\"formbg2\" type=\"text\" size=\"3\" maxlength=\"5\"><input type=\"hidden\" name=\"id\" value=\""; var pop7="\"><input type=\"hidden\" name=\"pri\" value=\""; var pop8="\"><input type=\"submit\" name=\"buy\" value=\""; var pop9="\" class=\"bgx2\" onMouseOver=\"className='bgx3'\" onMouseOut=\"className='bgx2';\"></td></tr><tr><td class=\"fromadmin-2\"><div align=\"right\"><a href=\"javascript:void(0);\" onClick=\"c=1; nd();\" class=\"celula-subject-fromadmin\">X</a></div></td></tr></table></form>"; var sp=" "; pop=pop1+id+pop2+desc+pop3+lpri+pop4+price+pop5+lbuy+sp+name+pop6+id+pop7+price+pop8+lbuy+pop9; overlib(pop, FGCOLOR, '', BGCOLOR, '#000000',BORDER, 0, OPACITY, 88, RELY, 120, RELX, 480); } Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037804 Share on other sites More sharing options...
Psycho Posted April 6, 2010 Share Posted April 6, 2010 "Doesn't work" doesn't provide any useful information. Did you check the error that were generated, because there would be one, what were they? Did you LOOK at the output created? If you had, I would think the problem would be obvious. You didn't state originally that the value could be anything other than a number. If the value is 's', the resulting code output to the browser would be: <a href='javascript:void(0);' onClick='zz(s,1,1,1,1,1)' > See anything wrong with that 's' now? Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037835 Share on other sites More sharing options...
razvypp Posted April 6, 2010 Author Share Posted April 6, 2010 there is no Error , it just doesn't send information to the zz function Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037843 Share on other sites More sharing options...
razvypp Posted April 6, 2010 Author Share Posted April 6, 2010 this is what output looks like <a href='javascript:void(0);' onClick='zz(1,1,1,Manna Biscuit,55,4)' ><img src='img/items/consumables/manna_b.jpg' /></a> and not error Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037860 Share on other sites More sharing options...
Psycho Posted April 6, 2010 Share Posted April 6, 2010 OK, I was trying to lead you to the answer instead of just blurting it out. You state in Reply #2 it doesn't work as in if $ico= any char character it doesn't work ex: $ico="1"; WORKS ex: $ico="s"; doesn't work But, in the last reply you state this is what output looks like <a href='javascript:void(0);' onClick='zz(1,1,1,Manna Biscuit,55,4)' ><img src='img/items/consumables/manna_b.jpg' /></a> and not error So, it would appear that is the output when $ico is '1' (when it works) and not 's', when it does not work. Also, where did 'Manna Biscuit' come from? You previous code showed that parameter as being hard coded with a 1. I already posted above what the output would look like when the value is 's'. The problem is that you cannot pass text in a function call unless it is enclosed in quote marks. Incorrect: onClick='zz(s,1,1,1,1,1)' Correct: onClick="zz('s',1,1,1,1,1)" Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037891 Share on other sites More sharing options...
razvypp Posted April 6, 2010 Author Share Posted April 6, 2010 maybe i didn't explain well enough . the 1,1,1,1,1,1 was am example , put there by me , so no 1 coding , i showed you the helm output , and that was good , the problem was that it didn't work (it should have shown a hidden tag.if you are familiar with overlib ) and it doesn't. currently i have like this and it works cause $ico and $price are numbers , but if they are chars no more hidden div print "<a href='javascript:void(0);' onClick='zz(1,1,$ico,0,$price,4)' >"; OK, I was trying to lead you to the answer instead of just blurting it out. You state in Reply #2 it doesn't work as in if $ico= any char character it doesn't work ex: $ico="1"; WORKS ex: $ico="s"; doesn't work But, in the last reply you state this is what output looks like <a href='javascript:void(0);' onClick='zz(1,1,1,Manna Biscuit,55,4)' ><img src='img/items/consumables/manna_b.jpg' /></a> and not error So, it would appear that is the output when $ico is '1' (when it works) and not 's', when it does not work. Also, where did 'Manna Biscuit' come from? You previous code showed that parameter as being hard coded with a 1. I already posted above what the output would look like when the value is 's'. The problem is that you cannot pass text in a function call unless it is enclosed in quote marks. Correct: onClick="zz('s',1,1,1,1,1)" doesn't work eighter , the div doesn't show . Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037897 Share on other sites More sharing options...
Psycho Posted April 6, 2010 Share Posted April 6, 2010 currently i have like this and it works cause $ico and $price are numbers , but if they are chars no more hidden div print "<a href='javascript:void(0);' onClick='zz(1,1,$ico,0,$price,4)' >"; As I stated, text needs to be passed enclosed in quotes. Try this: print "<a href=\"javascript:void(0);\" onClick=\"zz(1,1,'$ico',0,'$price',4)\" >"; If that does not work, then I don't know what to tell you. Text need to be enclosed in quotes in a function call. If that is fixed, then I would assume that the function zz() is expecting a number for some of the parameters that you are passing text. Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037909 Share on other sites More sharing options...
razvypp Posted April 6, 2010 Author Share Posted April 6, 2010 tnx mjdamato that is the answer !! tnx a lott Quote Link to comment https://forums.phpfreaks.com/topic/197754-java-and-php-variable/#findComment-1037931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.