[Freerealty] featured.php missing database name?
Scott Wang
scott at scottscomputing.com
Tue Apr 26 10:37:37 MST 2005
That's all true, however, getdb() is in the func.php file, right?
Where in common.php or featured.php does it pull in the func.php file? How
does it know what that function does?
- Scott Wang
-----Original Message-----
From: freerealty-bounces at lists.rwcinc.net
[mailto:freerealty-bounces at lists.rwcinc.net] On Behalf Of Patrick Fleming,
EA
Sent: Tuesday, April 26, 2005 11:08 AM
To: Continuation of Jon Roig's OR 2.x Development
Subject: Re: [Freerealty] featured.php missing database name?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Scott,
Wow. The database connection is setup through the function getdb();
Not only does it set up the user/password combination but selects the
$db database as well and should throw errors if it cannot connect.
If you have the line $link = getdb(); at the top of your files it should
connect. Not sure why it failed for you.... unless getdb() I believe
requires globals.
Scott Wang wrote:
| Argh! Another hair-puller. I just spent an hour trying to get the
featured
| listings to work and I think I found the problem.
|
| I had to add the ' $db. ' to the two mysql_query lines in order for it to
| stop throwing errors. I looked and couldn't figure out how the
mysql_query
| knew which database it was querying. After I did that, the two listings
| showed up correctly, images and all.
|
| This is the content of featured.php, with the two $db.'s that I added in
| red.
|
|
| //EXAMPLE CODE:
| //handles the listing of featured properties
| //Adding random rotation of images and a limit
| //Check to see if $noimages is set
|
| $result = mysql_query("SELECT distinct * from $db.".$table_prefix."homes
| WHERE featured = 'Y' AND status != 'Held' ORDER BY RAND() LIMIT $limit",
| $link);
|
| while ($a_row = mysql_fetch_array($result) )
| {
| //add commas to price
| $a_row['price'] = number_format ($a_row['price']);
| $a_row['title'] = stripslashes($a_row['title']);
| echo "<p /><a
| href=\"./propview.php?view=$a_row[id]\"><b>$a_row[title]</b></a><BR>";
| //select images connected to a given listing
| $query = "SELECT * FROM $db.".$table_prefix."tbl_Files WHERE prop_num =
| $a_row[id] LIMIT 1";
| $output = mysql_query("$query",$link);
| $count = 0;
| while ($image_row = mysql_fetch_array($output) )
| {
| print "<a href=\"propview.php?view=$a_row[id]\"><img
| src='image.php?Id=$image_row[id_files] &image=thumb' border=1 width=100
| alt=\"Photo\"></a><br>";
| $count++;
| }
| if($count == 0)
| {
| print "<a href=\"./propview.php?view=$a_row[id]\"><img
| src=\"./images/nophoto.gif\" border=1 width=100 alt=\"View
| Listing\"></a><br>";
| }
| // print "$a_row[beds] beds/$a_row[baths] baths<BR>
\$$a_row[price]<BR> <P
| />";
| }
|
|
| - Scott Wang
| Scott's Computing
|
|
|
|
| ------------------------------------------------------------------------
|
| _______________________________________________
| FreeRealty mailing list
| FreeRealty at lists.rwcinc.net
| http://lists.rwcinc.net/mailman/listinfo/freerealty
| FreeRealty web site: http://www.rwcinc.net/freerealty
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCbmdEGzHR7DxVKWIRAsugAJ434+kdgKaDwARdyl3zmTeCswrrUQCeJfhx
3GQE1LQVHzukAgkbxyJYGGo=
=YZUW
-----END PGP SIGNATURE-----
More information about the FreeRealty
mailing list