I'm not sure I care, because the script works as is should. But, I am a perfectionist, which one has to be when programming dumb computers.
Here's the code:
<?php
$host="localhost";
$user="root";
$password="g1G3m#1989";
$Dbname = "DispatchReports";
$cxn = mysql_connect($host,$user,$password)
or die (mysql_error() . "couldn’t connect to server");
mysql_select_db($Dbname, $cxn)
or die(mysql_error() . "couldn't select database");
$result = mysql_query("SELECT * FROM Techs", $cxn);
$num_rows = mysql_num_rows($result);
for ($TechCount = 1; $TechCount <= $num_rows; $TechCount++)
{
$Quest = "SELECT * FROM `DispatchReports`.`Techs` WHERE IDNum = '$TechCount'";
$result = mysql_query($Quest, $cxn)
or die ('Santa Claus is watching you' . mysql_error());
while ($row = mysql_fetch_array($result))
{
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$TechNum = $row['TechNum'];
$CellNum = $row['CellNum'];
$AreaCode = substr($CellNum, 0, 3);
$AreaCode = '(' . $AreaCode . ') ';
$Exchange = substr($CellNum, 3, 3);
$PhNum = substr($CellNum, 6);
$CellNumber = $AreaCode . ' ' . $Exchange . '-' . $PhNum;
echo $FirstName . ' ' . $LastName . ' ' . $CellNumber . '<br />';
$result = mysql_query("UPDATE `DispatchReports`.`Techs` SET `CellNum` = '$CellNumber' WHERE `IDNum` = $TechCount")
or die ("cannot update ". $TechNum);
}
}
The error is:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/FixCell.php on line 40
Jerry Elliott (979) 412-0539
Line 40 is:
while ($row = mysql_fetch_array($result))
This error is repeated for every iteration of $TechCount. I am flummoxed because I copied most of the lines of code from a page that worked. I have a similar script, and I'm getting the same error in the same line, but again, the script produced the results I am after.