r/PHPhelp • u/zephead98 • 2d ago
Solved Weird Echoing
So I have this script and when it gets to this point, it echos everything after $webuser=$db. I am completely stumped and claude just tells me there must be another "start php" somewhere in the $sSQL string. But there is not.
I will greatfully accept any and all input. (db is a database wrapper function that just connects to the db with the username and password).
//No errors on validation, insert/update record
if ($msgFormErr==""){
$sSQL="SELECT web_users_username, web_users_password, web_users_relid FROM webusers";
$webuser=$db->get_row($sSQL);
$username=$webuser->web_users_username;
$password=$webuser->web_users_password;
$webrelid=$webuser->web_users_relid;
$sSQL="SELECT studentcontact_email from studentcontact where studentcontact_id = $webrelid";
$email=$db->get_var($sSQL);};
?>
6
u/NumerousComplex1718 2d ago
by "it echos everything", you mean it's displaying the code instead of interpreting it? If so, make sure you have the <?php tag appropriately placed
8
u/flyingron 2d ago
Both the lines that start with $sqL="SELECT ...
do not have a closing ".
You might find it handy to use emacs, or PHPStorm, or some editor that colorizes the text that will call your attention to things like this.
3
u/ohnomybutt 2d ago
use a debugger.
1
u/zephead98 1d ago
I am going to mark this solved. Clearly I am not using all the available tools at my disposal, and our time will be better served by me taking a break, and installing and learning these tools.
I thank you all for your input! I am off to learn.
1
u/ray_zhor 1d ago
Check your filename extension. If it's not .php. then that's your problem. Or check to see if there is a ? Before > where it starts to display
1
u/colshrapnel 1d ago
It's very simple. If you would open the page source (instead of staring at the rendered picture), as you always should as a backend developer, you will see entire code echoed out.