Irish SEO,  Marketing & Webmaster Discussion
 

 

Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 20-02-2008, 06:51 PM
Frontpage User
 
Join Date: Apr 2007
Posts: 13
Keewee6 will become famous soon enough
Default php search code error

heres the error

Search For

Seach for: in Events Day
Results


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/squarebar/domains/nixysthesquarebar.com/public_html/search.php on line 44

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/squarebar/domains/nixysthesquarebar.com/public_html/search.php on line 56
Sorry, but we can not find an entry to match your query

Searched For: SATURDAY

here is the code

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Search For</h2>
<form name="search" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<option value="events">Events</option>
<option value="day">Day</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<?php
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// Otherwise we connect to our Database
mysql_connect("localhost", "squarebar", "square462") or die(mysql_error());
mysql_select_db("squarebar_db1") or die(mysql_error());
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'");
//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo $result['date'];
echo " ";
echo $result['day'];
echo "<br>";
echo $result['events'];
echo "<br>";
echo "<br>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
}
?>
</body>
</html>

any help would be good
Reply With Quote
  #2 (permalink)  
Old 20-02-2008, 08:42 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 1,923
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

compare with how you make a db connection to how it's shown here:

PHP MySQL Select

and you will notice the mistake.
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Reply With Quote
  #3 (permalink)  
Old 20-02-2008, 09:32 PM
ghost's Avatar
Wannabe Geek
 
Join Date: Dec 2007
Location: Ennis
Posts: 157
ghost will become famous soon enough
Default

Quote:
Originally Posted by Keewee6 View Post
mysql_connect("localhost", "squarebar", "square462") or die(mysql_error());
mysql_select_db("squarebar_db1") or die(mysql_error());
It is also better to put your db connection in a separate file and include it on your working pages.
like this
PHP Code:
$host 'localhost';
$user 'squarebar';
$pass 'square462';
$db 'squarebar_db1';
$con mysql_connect($host$user$pass) or die('ERROR: I Cant find the database!');
mysql_select_db($db) or die('ERROR: still Cant find it fix my db config file!'); 
in your working page do an

include('config.php');
If your Data base ever changes you will only need to make changes in one place
Reply With Quote
  #4 (permalink)  
Old 20-02-2008, 09:58 PM
Forbairt's Avatar
respect my AW-THOR-IT-AYY
 
Join Date: Jun 2007
Location: My Office, Dublin
Posts: 1,664
Forbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond reputeForbairt has a reputation beyond repute
Send a message via AIM to Forbairt Send a message via MSN to Forbairt Send a message via Yahoo to Forbairt Send a message via Skype™ to Forbairt
Default

also not the best idea to post these details on a public site

Giving us your domain name ... your database username / password ... and so on
__________________
Forbairt Media | Web Design & Development Galway / Dublin, Ireland - coming soon ... ( vague but descriptive isn't it )

Recent Work: Safari Club African Safari Holidays - Botswana Safaris
Reply With Quote
  #5 (permalink)  
Old 20-02-2008, 10:24 PM
ghost's Avatar
Wannabe Geek
 
Join Date: Dec 2007
Location: Ennis
Posts: 157
ghost will become famous soon enough
Default

yes , but with his new bd include file he can change them every day
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby on Rails VS PHP Code Igniter gav240z Coding Help 10 03-02-2008 11:04 PM


All times are GMT +1. The time now is 06:21 AM.


Powered by: vBulletin Version 3.7.2, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.

Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56