What is wrong in my code - TechRepublic
Question
February 10, 2010 at 09:32 AM
ivoyanev

What is wrong in my code

by ivoyanev . Updated 16 years, 4 months ago

Hi,

I am trying to collect data from MySQL and to assign the result to a PHP variable for further processing, but no assigment is made – the variable is empty:( here is the code

$name = $_GET[‘companyName’];

$index = $_GET[‘indName’];

$db_name = “clients”;

$connection = mysql_connect(“localhost”, “user”, “pass”) or die(“Could not connect.”);

mysql_select_db($db_name,$connection);

$query = “Select companyID from company where name= ‘”.$name.”‘ and indexNAME= ‘”.$index.”‘”;

// I check the query and it’s OK – return the correct value

$result = mysql_query($query, $connection) or die (“Could not execute query”);

while ($row = mysql_fetch_array($result));

{
echo “$row[0] gragra”;
$companyID = $row[0];
}

echo “$companyID blabla “;

the output is gragra blabla

Can someone explain me what I am doing wrong.

Thanks

This discussion is locked

All Comments