[thelist] MySQL/PHP Search

Ken Moore cor412 at hotmail.com
Wed Sep 3 17:25:52 CDT 2003


Jen,

This is almost certainly a permissions problem. You need to have the 
following permissions:

Connetion priviledge - Read about the "user" table";
Priviledges to a specific database - Read about the "db" table;
Specific permissions to the table such as select, insert, etc. - Read about 
the "tables_priv" table;

>From the mysql prompt, type "use mysql;" to see the system priviledges 
tables.
Then type "show tables;" and you will see the tables mentioned above.

The specific error sounds like your new user name does not have an entry in 
the db table that allows that user to access that table.

Ken

>From: Jennifer Zelazny <web at calgb.org>
>Reply-To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
>Subject: [thelist] MySQL/PHP Search
>Date: Wed, 3 Sep 2003 15:03:51 -0500
>MIME-Version: 1.0 (Apple Message framework v552)
>Received: from acornparenting.org ([216.40.227.23]) by 
>mc2-f27.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Wed, 3 Sep 
>2003 14:05:00 -0700
>Received: (qmail 25360 invoked from network); 3 Sep 2003 20:04:12 -0000
>Received: from localhost (HELO www.acornparenting.org) (127.0.0.1)  by 0 
>with SMTP; 3 Sep 2003 20:04:12 -0000
>Received: (qmail 25282 invoked from network); 3 Sep 2003 20:03:49 -0000
>Received: from moof.uchicago.edu (HELO calgb.org) (128.135.31.6)  by 0 with 
>SMTP; 3 Sep 2003 20:03:49 -0000
>Received: from [128.135.31.51] (account web HELO calgb.org)by calgb.org 
>(CommuniGate Pro SMTP 4.1)with ESMTP id 976711 for 
>thelist at lists.evolt.org;Wed, 03 Sep 2003 15:03:52 -0500
>X-Message-Info: JGTYoYF78jHIXrRWgI2TukfK3WHO5L0J
>Return-Path: <web at calgb.org>
>Delivered-To: thelist at lists.evolt.org
>In-Reply-To: <opruxq0oserjd11h at smtpx.operamail.com>
>Message-Id: <BD243931-DE49-11D7-A344-000393CB09A8 at calgb.org>
>X-Mailer: Apple Mail (2.552)
>X-Content-Filtered-By: Mailman/MimeDel 2.1b5
>X-BeenThere: thelist at lists.evolt.org
>X-Mailman-Version: 2.1b5
>Precedence: list
>List-Id: thelist at lists.evolt.org <thelist.lists.evolt.org>
>List-Help: <mailto:thelist-request at lists.evolt.org?subject=help>
>List-Post: <mailto:thelist at lists.evolt.org>
>List-Subscribe: 
><http://lists.evolt.org/mailman/listinfo/thelist>,<mailto:thelist-request at lists.evolt.org?subject=subscribe>
>List-Archive: <http://lists.evolt.org/pipermail/thelist>
>List-Unsubscribe: 
><http://lists.evolt.org/mailman/listinfo/thelist>,<mailto:thelist-request at lists.evolt.org?subject=unsubscribe>
>Sender: thelist-bounces at lists.evolt.org
>Errors-To: thelist-bounces at lists.evolt.org
>X-OriginalArrivalTime: 03 Sep 2003 21:05:00.0713 (UTC) 
>FILETIME=[09B9B190:01C3725F]
>
>Hello.  I have a need to have my users search our MySQL database which 
>contains people's names, phone numbers, etc so I found an example here: 
>http://www.thinkhost.com/services/kb/php-mysql-forms.shtml and copied and 
>pasted everything exactly like the article stated so I could see how this 
>worked.  I only changed the hostname, username, and password.  I set up a 
>test database that was exactly like the one they used, so the only 
>difference should by my hostname, username, password.  I have other 
>PHP/MySQL applications running on my server which I supply the same 
>hostname, username, and password information that work great, but I cannot 
>figure out why this is failing.  If anyone has any ideas or thoughts...or 
>working examples of a php/mysql search that I could look at, I would 
>greatly appreciate it.
>
>I get a parse error on the line: MYSQL_CONNECT($hostname, $username, 
>$password) OR DIE("DB connection unavailable");
>
>Thanks in advance,
>Jen
>
>-----------------
>My code for the results page:
>
><html>
><head>
><title>Test</title>
></head>
><body bgcolor="#ffffff">
><center>
><table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
><tr>
><td width="60"><b>id</b></td>
><td width="100"><b>name</b></td>
><td width="70"><b>telephone</b></td>
><td width="150"><b>birthday</b></td>
></tr>
><tr>
><td>
><? $hostname = "128.x.x.x"; // The DB server. 
>$username = "root"; // The username you created for this database.  
>$password = "xxxxx"; // The password you created for the username.  
>$usertable = "details"; // The name of the table you made. 
>$dbName = "example"; // This is the name of the database you made. 
>MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection 
>unavailable");
>@mysql_select_db( "$dbName") or die( "Unable to select database"); 
>?> 
><? 
>//error message (not found message)begins 
>$XX = "No Record Found, to search again please close this window"; 
>//query details table begins
>$query = mysql_query("SELECT * FROM details WHERE $metode LIKE '%$search%' 
>LIMIT 0, 50"); 
>while ($row = @mysql_fetch_array($query)) 
>>$variable1=$row["id"];
>$variable2=$row["name"]; 
>$variable3=$row["telephone"]; 
>$variable4=$row["birthday"];
>//table layout for results 
>
>print ("<tr>");
>print ("<td>$variable1</td>"); 
>print ("<td>$variable2</td>"); 
>print ("<td>$variable3</td>"); 
>print ("<td>$variable4</td>"); 
>print ("</tr>"); 
>}
>//below this is the function for no record!!
>if (!$variable1)
>>print ("$XX");
>>//end 
>?>
></table>
></center>
>
></body>
>
></html> --
>* * Please support the community that supports you.  * *
>http://evolt.org/help_support_evolt/
>
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !

_________________________________________________________________
Get MSN 8 and enjoy automatic e-mail virus protection.   
http://join.msn.com/?page=features/virus



More information about the thelist mailing list