whats wrong with my code please help!!!
Posted on
16th Feb 2014 07:03 pm by
admin
this is the error
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /var/www/IpSearch.php on line
Code: [Select]<?php
$srch = $_REQUEST["srch"];
if (empty($srch)) {
print <<<HERE
<form>
Type the Store location:
<input type = "text"
name = "srch">
<input type = "submit">
</form>
HERE;
} else {
$con = mysql_connect("localhost","root","icebird");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("IpPhoneDir", $con);
// Send a query to the server
if ($result = mysql_query($con, "call GetBranchBeg($srch)")) {
$um_rows = mysql_num_rows($result);
if($num_rows <= 0) {
echo "no match found";
}
print "<table border = 1>n";
//get row data as an associative array
While ($row = mysql_fetch_assoc($result)) {
print "<tr>n";
//look at each field
foreach ($row as $col=>$val){
print "<td>$val</td>n";
}//end foreach
print "</tr>nn";
}//end while-
print "</table>n";
} else {
trigger_error(mysql_error(),E_USER_WARNING); //this will display MySQL's error message
}
}
mysql_close($con)
?>
Code: [Select]DROP PROCEDURE `GetBranchBeg`//
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchBeg`(IN starts_with CHAR(15))
BEGIN
DECLARE tmp CHAR(15);
SET tmp = CONCAT(starts_with, '%');
SELECT IpPhoneNo, location FROM IpPhoneList WHERE location LIKE tmp OR location =starts_with;
END
No comments posted yet
Your Answer:
Login to answer
296
8
Other forums
New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan
Customizing message/behavior
Hi,I'm using the ASP.NET membership/authorization controls in my application. Some parts of my appli
Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:
http://www.mydomain.com/directory/index.php
form help
this doesn't work. i want the form action to go the location.href of the submit button chosen.. how
Database/Table Collation
What is the Database, and table collations used for? i don't understand what there used for since co
compile php5 with DOM
Hi,
I can't manage to compile php 5.3.0 from source on Windows to include DOM,
in spite of
Setting condidtions for an input box
Hi all,
I would like to set a condition in a txt box that says the number a user enters has t
Help building / using array
First - this is a cross-posting, if this is wrong I apologise! What started out as a MySQL query que
Problem in back link
I have page where i have given javascript back link but when i click on it browser give a message
Insert Failing.
Hey,
I am making a Sign up page for a website, but the insert query into the Database does not se