Copy value of variable#1 to variable #2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MCouche
Forum Newbie
Posts: 3
Joined: Mon Feb 15, 2010 10:10 am

Copy value of variable#1 to variable #2

Post by MCouche »

Hello,

In order to implement a business rule, I need to save the value of a specific column found in the first row of a data set into a variable. I have no problem with the database/query aspect (thanks to the support provided by the forum yesterday). The issue arises when I transfer the returned value from one variable into another (.i.e. comment line in red below)

$dbh = new PDO("mysql:dbname=olr_master;host=localhost", "----", "-----" );

$QueryHelper = new EMail_Helper();
$sql = $QueryHelper->Query_reports_to_email_to_vetos();

$rows = $dbh->query($sql);

// we retrieve the first row from the dataset
$firstrow_vet = $rows->fetch();

// we transfer the ID of the first vet into a variable for later use
$current_vet = $firstrow_vet['Vet_ID'];
echo "1. First row ID is {$firstrow_vet['VET_ID']}<br>";
echo "2. First row ID is {$current_vet}<br>";
.....

When I run the code, the output shows that I failed transferring the value from one variable to the second. Indeed, the code returns:
1. First row ID is 990006975
2. First row ID is

Thank you,

Michel
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Copy value of variable#1 to variable #2

Post by AbraCadaver »

Variables are case sensitive. Do you see a problem?

Code: Select all

$firstrow_vet['Vet_ID']
{$firstrow_vet['VET_ID']}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply