I have a simplified ajay script, from which I have removed all nonrelevant code. The problem I am having is first with my columns array and the subsequent foreach loop. I want to go through each element and change the corresponding element to YES if true and NO if false, I don't see why it isn't working.
If there are any problems such as syntax errors or braces or such, they are a problem from simplifying my code, and are not present in the version on my machine.
<?php
$con = mysqli_connect("localhost", "", "", "");
if (!$con) {
echo "Can't connect to MySQL Server. Errorcode: %s\n". mysqli_connect_error();
exit;
}
$con->set_charset("utf8");
$query1 = 'SELECT EGGS, SALAD, TREES, REVISED FROM AUCTIONS WHERE ARTICLE_NO = ?';
if ($getRecords = $con->prepare($query1)) {
$getRecords->bind_param("s", $pk);
$getRecords->execute();
$getRecords->bind_result($EGGS, $SALAD, $TREES, $REVISED);
while ($getRecords->fetch()) {
$columns = array('EGGS', 'SALAD', 'TREES', 'REVISED');
foreach($columns as $column) {
$$column = $columns[$column] ? 'YES' : 'NO';
}
imageSize = imageResize($PIC_URL, 250, 300);
echo "<h1>".$EGGS."</h1>";
}
}
function imageResize($imageURL, $maxWidth, $maxHeight) {
$imageSize["width"] = 0;
$imageSize["height"] = 0;
$size = getimagesize($imageURL);
if ($size) {
$imageWidth = $size[0];
$imageHeight = $size[1];
$wRatio = $imageWidth / $maxWidth;
$hRatio = $imageHeight / $maxHeight;
$maxRatio = max($wRatio, $hRatio);
if ($maxRatio > 1) {
$imageSize["width"] = $imageWidth / $maxRatio;
$imageSize["height"] = $imageHeight / $maxRatio;
return $imageSize;
} else {
$imageSize["width"] = $imageWidth;
$imageSize["height"] = $imageHeight;
return $imageSize;
}
} else {
die(print_r(error_get_last()));
}
}