- This topic is empty.
-
AuthorPosts
-
April 21, 2015 at 12:52 pm #200905
[email protected]
ParticipantHey,
I am writing a php script for an sql query and all it is returning is a dot and not the correct info although the query works in sql developer.
<?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.’‘;
echo ‘<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.’
‘;
?>Thanks
Ben
April 23, 2015 at 2:38 am #200962bochristensen
ParticipantYour 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; ?>
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.