What is wrong with this php?

<option value="<? print $vd[$i]; ?>"><? print $vd[$i]; . " - $" . number_format($vp[$i],0) ?></option>

Open in new window


This gives a syntax error. Also syntax error if I use print number_format.

Earlier definition of $vd & $vp:
$qry = "SELECT * from products where Model = '" . $_SESSION['model'] . "' and App = '" . $clname . "'";
	//echo "qry for purge prices = " . $qry . "<br>";
	$res = mysqli_query($link, $qry);
	$p = mysqli_fetch_array($res,MYSQLI_ASSOC);
	$vd = array();
	$vd [0] = '208V 60 Hz';
	$vd [1] = '230V 60 Hz';
	$vd [2] = '460V 60 Hz';
	$vd [3] = '575V 60 Hz';
	$vd [4] = '380V 50 Hz';
	$vd [5] = '415V 50 Hz';
	$vp = array();
	$vp[0] = $p['208V_60Hz'];
	$vp[1] = $p['230V_60Hz'];
	$vp[2] = $p['460V_60Hz'];
	$vp[3] = $p['575V_60Hz'];
	$vp[4] = $p['380V_50Hz'];
	$vp[5] = $p['415V_50Hz'];

Open in new window

Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
$p is an array.  Is $p['208V_60Hz'] a column in the table you fetched?  For number_format, does it contain Only float numbers?

http://php.net/manual/en/function.number-format.php
0
hieloCommented:
On your second print statement
>> print $vd[$i]; . “ - $”

you have a semicolon to the left of the first dot (concatenation operator). Get rid of the semicolon.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard KortsAuthor Commented:
Dave, yes to all those.

I will try hielo's suggestion
0
NerdsOfTechTechnology ScientistCommented:
What is the value of $vp[$i]? Maybe use sprintf() instead?:

<option value="<?php echo $vd[$i]; ?>"><?php echo $vd[$i] . " - $" . sprintf("%01.2f", $vp[$i]); ?></option>

Open in new window

0
Richard KortsAuthor Commented:
Fixed it right away.

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.