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
PHP and Javascript
Hello Everyone,
I have a page that needs a javascript code to be written between PHP code but
Displaying a record from mysql in a simple swf file
Hi,
I have a mysql database containing information I would like to display in my swf.
rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the sam
Undefined variable: adHTML
Hello:
While checking my site error logs, I've noticed one repetitive error that fills the lo
Securing a user input - need some confirmation
Hello All,
I am in the process of recoding a large proportion of an e-commerce site, one of t
remove innitial and
tags
i am using tiny_mce as a text editor for my CMS.
buy now the problem is it add <p>
BB_Code error
I'm having a problem with a custom built function and keep getting this error:
Warning: M
include function being weird?
I have a very simple system to grab an IP outputted by a PHP file.. (for a project I have) but it ou
Help with form post data and arrays
Hi all,
I am new to this forum... It has been awhile since i have worked with arrays, and i a
Rounding a number queried from a database
I know that to display a rounded number you just do echo "round($number)";. But how would