Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End SQL To PHP Help Reply To: SQL To PHP Help

#200962
bochristensen
Participant

Your single and double quotes look like quotation marks, and there’s a few places, where you have two single quotes after each other.

Please try to following code.

<?php

// remove these style tags to remove the large font size
echo '<style type="text/css"> p {font-size: x-large;} </style>';
echo '<style type="text/css"> table {font-size: x-large;} </style>';
// Accept a parameter called “name” from a form.
$name = $_POST['name'];
echo 'Parameter value was: ' . $name . '<br/><br/>';

// Connect to the Oracle database
require('x_connect.php');

// Specify SQL STATEMENT CONTAINING A BIND VARIABLE
$query1 = "SELECT LOCNAME AS Organisation, category AS Category, locx AS LOCX, locy AS LOCY 
    FROM BBT_Location 
    WHERE LOCNAME LIKE '%'||upper(:name)||'%' and postcode is not null";

// Parse the query containing a bind variable.
$stmt = oci_parse($conn, $query1);

// Bind the value into the parsed statement.
oci_bind_by_name($stmt, ':name', $name);

// Execute the completed statement.
oci_execute($stmt);

echo '<table border="1" cellpadding="5">'."n";
while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo '<tr>'."n";
    foreach ($row as $item) {
        echo '<td>' . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . '</td>'."n";
    }
    echo '</tr>'."n";
}
echo '</table>'."n";

// Release the statement variable and close the connection
oci_free_statement($stmt);
oci_close($conn);

// Show the SQL
echo 'SQL statement executed was: </br>' . $query1;

?>