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 Like 8 Dislike
Previous forums Next forums
Other forums

How can I Compare two xml documents?
Hi all,

I am doing a POC for my project and I am using XE database 10g version.

Strange PHP/mySQL error ... am I just tired?
Code: <?

## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostNam

Allowing ' and "
Hello everyone,

I am creating a form where users submit information to go into a database. I

Lining up columns nicely.
Hello everyone, I'm having problems with making columns line up properly. Here is my code:

New to mysqli library - Multiple query problem
Greetings,

I am writing a batch program that executes 3 queries on a single page. Using mysql

Help with usergroups? prolly really quick
So were coding our own forums for a game system we made an we have the users level setup but now I n

IIS & NW MII on the same server
Hi,

We're weighing the possibility to run both IIS and MII (NetWeaver) on the same server

Setting/Modify Headers using mail() function
I have a question about setting email headers when using mail() in a php script.

When I send

help countdown timers
hello every one,

I'd like to know how to insert many countdowns in the same page.
The dura

[PHP HELP] Php order form.
Hello to everyone @ phpfreaks. Im new to this site and hope to learn lots of things here.

Fir

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash