[PHP-DB] Resource id #2
Hello. I am using MySQL as a database for a departmental library. I have written a quick search script, but keep getting resource id #2 as a result to my search. I have read the online documentation for the mysql_fetch_array() function and must say, I don't see that I'm missing anything. However, I've only started programming, much less working with PHP, so perhaps someone can help me out. Here's my code: ? $quickSearch = mcse; $table1 = Books; $table2 = BookList; $table3 = BoxSet; $table4 = Category; $table5 = Publisher; $table6 = AuthUsers; $table7 = CD; $connection = mysql_connect(localhost, root) or die(Couldn't connect to the library database.); $db_select = mysql_select_db(library, $connection) or die(Couldn't select the library database.); $search = SELECT * FROM $table1 LEFT JOIN $table2 ON Books.BookListID = BookList.BookListID LEFT JOIN $table3 ON Books.BoxSetID = BoxSet.BoxSetID LEFT JOIN $table4 ON Books.CategoryID = Category.CategoryID LEFT JOIN $table5 ON Books.PublisherID = Publisher.PublisherID LEFT JOIN $table6 ON Books.auID = AuthUsers.auID LEFT JOIN $table7 ON Books.CD = CD.CD_ID WHERE Books.Title LIKE \%'$quickSearch'%\ OR Books.Author LIKE \%'$quickSearch'%\ OR Books.ISBN LIKE \%'$quickSearch'%\ OR BookList.dbase LIKE \%'$quickSearch'%\ OR BookList.dbase_user LIKE \%'$quickSearch'%\ OR BoxSet.BoxSet LIKE \%'$quickSearch'%\ OR Category.Category LIKE \%'$quickSearch'%\ OR Category.Sub_category LIKE \%'$quickSearch'%\ OR Publisher.Publisher LIKE \%'$quickSearch'%\; $result = mysql_query($search, $connection) or die(Couldn't search the library.); while ($row = mysql_fetch_array($result)) { $row['Books.Title']; $row['Books.Author']; $row['Books.ISBN']; $row['BookList.dbase']; $row['BookList.dbase_user']; $row['BoxSet.BoxSet']; $row['Category.Category']; $row['Category.Sub_category']; $row['Publisher.Publisher']; $row['AuthUsers.email']; } ? I then have some HTML to display the result of the search. I don't receive any error messages - I just see an empty table from the HTML code I wrote. I added an echo of the $result to find the resouce id #2. Thanks for any help you can provide. --joel _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] User Defined Function Problem
Does anyone see anything I might be missing as to why this won't work? From the file calling the function: ?php $round = Round 1; $region = East; include check.php; isAuthorized($_COOKIE['username'], $_COOKIE['password']); include checkEntry.php; check4Entry($username, $round, $region); ... From checkEntry.php: ?php function check4Entry($name, $reg, $rnd) { $connection = mysql_connect(localhost, root) or die(mysql_error()); $db = mysql_select_db(marchmadness, $connection) or die(mysql_error()) ; $checking = SELECT * FROM pick WHERE userID = \$uname\ AND round = \$rnd\ AND region = \$reg\; $result = mysql_query($checking, $connection) or die(mysql_error()); $numRows = mysql_num_rows($result) or die(mysql_error()); if ($numRows 0) { print(htmlheadlink rel=\stylesheet\ type=\text/css\ href=\bbb.css\/headbodycentertable class=\outTbl\trth align=\center\ class=\outTh\ Oops! There are already selections made for $uname in $reg - $rnd. /th/tr trtd$uname, if you'd like to modify your selections, please click a href=\modifyEntry.php\here/a./td/tr/table/center/body/html); exit; } } ? == When I submit the form, I get a blank screen as a result. There aren't any errors ouput to the screen. I've compared this with another function I've created, and there doesn't appear to be anything different. The latter works. BTW, I bet you'll never guess what this is for...;-) Thanks for your help! --Joel _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Reading File Contents
Hello. I have what should be a simple fix for the more advanced programmers out there. I'm having problems with the display format of a text file. I've been reading several resources, and I'm just not having much success with it. How would you be able to display the following file named test.txt: 1. Test 2. Test 3. Test ...without it displaying like: 1. Test 2. Test 3. Test? I've tried the nl2br function, as well as adding \n to the end of each line and using fgets to replace \n with br. However, nothing seems to be working. I'm probably missing something very simple, but if someone wouldn't mind helping a rookie out, I'd appreciate it. --Joel _ Help protect your PC: Get a free online virus scan at McAfee.com. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php