Long story short, I’m running through a PHP/MySQL for Dummies ebook.
I’ve attempted to run a sample script from it on my server but it doesn’t work. I think it doesn’t like the kind of quotation marks used.
Is this a problem with how my server is set up? Or is the guide wrong or out of date? (I changed the database options to my own as instructed)
The error I am getting is
Parse error: syntax error, unexpected ‘>’ in /home/content/t/a/k/takshack/html/php/sqltest.php on line 6
Changing the " to ’ solves it but there are so many instances of this that I can’t be bothered to find which ones are correct and which ones aren’t.
[php]<?php
/*Program: mysql_send.php
*Desc: PHP program that sends an SQL query to the
- MySQL server and displays the results.
*/
echo “
Query: {$_POST[‘query’]}
Results
”; if($result == false) { echo “
Error: “.mysqli_error($cxn).”
”; } elseif(@mysqli_num_rows($result) == 0) { echo “Query completed. No results returned.
”; } else { /* Display results */ echo “”.$field->name.” | ”; } echo “
---|
”.$value.” | ”; } echo “
”; exit(); } /* Displays form for query input */ if (@$_POST[‘queryButton’] != “Edit Query”) { $query = “ “; } else { $query = str_replace(“%&%”,”’”,$_POST[‘query’]); } ?> ” method=”POST”>
Type in database name | > |
Type in SQL query | <?php echo $query ?> |