I need some help, and I don't know where else to turn. 3 years ago, there were a handful of PHP coding forums that offered plenty of help. But for whatever reason (PHP is out of favor and so are forums?), they aren't active anymore.
So the error I'm getting is "Fatal error: Can't use function return value in write context in /Users/lholcombe/Sites/triple-bypass/process3.php on line 84". Which I'm sure is related to the function reference variables I am passing. I didn't want to use things like reference variables specifically because I knew it would fuck things up. But I didn't know how else to get the effect I wanted.
Any assistance would be greatly appreciated.
The line in question is:
if (count($input1) = 1) {
And here's the whole code, for context (the line above is found in function_buildform3):
<?php
$prefix1 = $_POST['prefix1'];
$name1 = $_POST['name1'];
$type1 = $_POST['type1'];
$suffix1 = $_POST['suffix1'];
$prefix2 = $_POST['prefix2'];
$name2 = $_POST['name2'];
$type2 = $_POST['type2'];
$suffix2 = $_POST['suffix2'];
$success = 1;
$output = 1;
street_process($prefix1,$name1,$type1,$suffix1,1,$success,$output);
if ($success == 0) {
not_found(1);
}
else {
$output1=$ouput;
}
$success = 1;
$output = 1;
street_process($prefix2,$name2,$type2,$suffix2,2,$success,$output);
if ($success == 0) {
not_found(2);
}
else {
$output2=$ouput;
}
build_form3($output1,$output2);
// End main function
// function street_process
function street_process($prefix,$name,$type,$suffix,$iteration,&$success,&$output)
{
$name = strtoupper($name);
$conn_string = "host=localhost port=5432 dbname=testKCstreets user=postgres password=*******";
$db = pg_connect($conn_string);
$query="SELECT fullname FROM streets.roadtest WHERE st_name='$name'";
if ($prefix != "0") {
$query .= " AND dirprefix='$prefix'";
}
if ($suffix != "0") {
$query .= " AND dirsuffix='$suffix'";
}
if ($type != "0") {
$query .= " AND st_type='$type'";
}
$result = pg_query($db, $query);
if (!$result) {
echo "An error occured.\n";
exit;
}
for ($i=0; $i<pg_numrows($result); $i++){
$result_list[$i] = pg_fetch_result($result, $i, "fullname");
}
if (is_null($result_list[0])) {
return $success = 0;
}
else {
$output = array_unique($result_list);
sort($output);
return;
}
}
//function not_found
function not_found($iteration)
{
echo "Street number $iteration was not found.<br>";
echo "Please make sure the street you are searching for is in King County.<br>";
echo "Also, please check your spelling.<br>";
echo "Click the button below to return to the previous page.<br>";
echo "<form name=\"form2\" action=\"street_intersect.htm\"><input type=\"button\" value=\"Return\"></form>";
exit;
}
// function build_form3
function build_form3($input1,$input2)
{
echo "<form name=\"form3\" action=\"intersect.php\" method=\"post\">";
if (count($input1) = 1) {
echo "Street number 1 is:<br>";
echo $input1[0];
}
else {
echo "Multiple results were found for street number 1. Please select one:<br>"
for ($i=0; $i<count($input1); $i++){
echo "<input type=\"radio\" name=\"street1", $i, "\" value=\"", $input1[$i], "\">";
echo $input1[$i];
echo "<br>";
}
}
echo "<br><br>";
if (count($input2) = 1) {
echo "Street number 2 is:<br>";
echo $input2[0];
}
else {
echo "Multiple results were found for street number 2. Please select one:<br>"
for ($i=0; $i<count($input2); $i++){
echo "<input type=\"radio\" name=\"street2", $i, "\" value=\"", $input2[$i], "\">";
echo $input2[$i];
echo "<br>";
}
}
echo "<br><br>";
echo "If these values are correct, click <i>Submit</i>.<br>";
echo "Otherwise, click <i>Return</i> to try again.<br>";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\">";
echo "<input type=\"button\" name=\"return\" value=\"Return\" a href=\"street_intersect.htm\">";
echo "</form>";
exit;
}
?>
For the record, I'm 100% self taught in PHP. I did some modifications in phpBB a few years ago, but this is my first time trying to build something from the ground up. Pretty much everything I know comes from the PHP.net documentation, which I found last week.