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
Did you know?Explore Trending and Topic pages for more stories like this.


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

simple php table loop
Hi all,

I've the following code

<?php // Create category options

Multiple forms on the same page (safari)
Hello everyone,

I have 3 forms on the same page, that opens in a new window and submits to a

breaking a text file into paragraphs based on strings
I have a text file of email addresses that is all squished together. It looks like this:

abc

Multi language - seo links
Im trying to figure out the best method to have a multi language website that will function with seo

PHP form authentication
Hi guys,

what am trying to achieve is this: Whenever a user tries to login to my website, an

is this the proper use of mysql_real_escape_string() to prevent sql injections?
i was wondering is this the proper use of mysql_real_escape_string() to prevent sql injections? any

PHP code for a proxy
I was wondering which function I could use to create an online proxy tool. I was thinking cURL would

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

adding 0 to numbers
Hey guys i need to create a 00001 number in a loop. Is there a better way of forcing a 5 digit numbe

Custom list order
Hi there,

I have checked this tutorial and it's great till the point where I want to display

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