[Techtalk] MySQL & PHP upgrade issues

James james at james-web.net
Fri Jul 12 15:18:56 EST 2002


Variables not getting sent to the script...

Is your register_globals sent to on or off in php.ini?

I'd recommend leaving it on "off" and using the superglobals stuff, like
$_POST['varname']; where varname would be  'order' or such.  If your
using the GET method (pulling the variables from the URL), you would use
$_GET['varname'];

Lets try this now.

One thing I've always done with my PHP is put the SQL call into a
variable, like this:

$sql = "SELECT * FROM wherever ORDER BY blah DESC";

And then call the mysql_query.

Lets try this.

/* ----Begin code---- */

$term = $_POST['term'];	// Easier usage inside the script.

/* You might want to consider using switch() here instead of if */

if($_POST['order'] == "D") {

$sql = "SELECT * FROM cases WHERE title_e like '%$term%' or title_f like
'%$term%' or headnote_e like '%$term%' or headnote_f like '%$term%";

}

if($_POST['order'] == "N") {

$sql = "SELECT * FROM cases WHERE (title_e like '%$term%' or title_f
like '%$term%' or headnote_e like '%$term%' or headnote_f like
'%$term%') and (nancy = 'Y' and warren = 'N') ORDER by year DESC,volume
DESC,page DESC"; 

// You have to specify a direction, ASC or DESC when using ORDER.

}

$result = mysql_query($sql);

/* For error checking */

if(!$result)
{

echo("<p>Error performing query: " . mysql_error() . "</p>"); 

exit(); 

}

/* ----End code---- */

Let me know how that works.

- James

> -----Original Message-----
> From: techtalk-admin at linuxchix.org
> [mailto:techtalk-admin at linuxchix.org] On Behalf Of Davis, Jennifer
> Sent: Friday, July 12, 2002 2:54 PM
> To: techtalk at linuxcchix.org
> Subject: RE: [Techtalk] MySQL & PHP upgrade issues
> 
> 
> James:
> 
> 	Thank you so much for your help.
> 
> ------
> 
> Warning: Host 'soleil.jenn.ca' is not allowed to connect to
> this MySQL server in /var/www/htdocs/scc/output.php on line 46
> 
> Warning: MySQL Connection Failed: Host 'soleil.jenn.ca' is
> not allowed to connect to this MySQL server in 
> /var/www/htdocs/scc/output.php on line 46
> 
> Unable to connect to the database server at this time.
> 
> ------
> 
> 
> Upon discovering this, it was easy to fix the problem getting
> in to the database.  I just granted all permissiions to 
> root at soleil.jenn.ca
> 
> 
> Now I am getting a second error.
> 
> 
> ---------
> new search
> modify exisiting results
> Warren's Collection , Nancy's Collection , HRLS Collection
> 
> Sort by order published , alphabetically English ,
> alphabetically French , date of judgment
> 
> Print with headnotes , without ,
> 
> >From first volume of to last volume of
> 
> Error performing query:
> Case/ Arret
> 
> -----
> 
> The code for that part of the script is below:
> 
> 
> 
> if ($order=="D")
> {
> $result = mysql_query("SELECT * FROM cases WHERE (title_e
> like '%$term%' or title_f like '%$term%' or headnote_e like 
> '%$term%' or headnote_f like '%$term%')$
> 
> }
> 
> if ($order=="N")
> {
> $result = mysql_query("SELECT * FROM cases WHERE (title_e
> like '%$term%' or title_f like '%$term%' or headnote_e like 
> '%$term%' or headnote_f like
> '%$term%') and (nancy== 'Y' and warren == 'N') ORDER by 
> year,volume,page");
> 
> }
> /*
> for error checking
> $result = mysql_query("SELECT * FROM cases ORDER by
> year,volume,page"); */
> 
> if (!$result)
> {
> echo("<P>Error performing query: ".mysql_error()."</P>"); exit(); }
> 
> 
> -----
> 
> It seems that the both the variables are not getting passed
> to the script properly and the database is not getting read 
> at all.  If I remove the comment around:
> 
> /*
> for error checking
> $result = mysql_query("SELECT * FROM cases ORDER by
> year,volume,page"); */
> 
> Then I get no results.  I am starting to worry now.  This
> problem is above my head.  I am not looking forward to 
> entering another 500KB of data with a new database...
> 
> Thanks for the help so far.
> 
> Jenn
> 
> 
> 
> 
> 
> 




More information about the Techtalk mailing list