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 KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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?

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.

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 KortsBusiness Owner / Chief DeveloperAuthor Commented:
Dave, yes to all those.

I will try hielo's suggestion
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

Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
Fixed it right away.

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

From novice to tech pro — start learning today.