PHP5 + Mysql 5 + Abyss - Error 404 Not found

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
darrenfinch
-


Joined: 19 Jan 2006
Posts: 6

PostPosted: Thu Mar 16, 2006 4:40 pm    Post subject: PHP5 + Mysql 5 + Abyss - Error 404 Not found Reply with quote

Hi all,

I am trying to get the following to work (the only info in our library is for PHP 4 so this could be part of the issue!), everytime I run this and enter a select query (i.e. select * from mice) I get the
Quote:
Error 404
.

Anyways the script is from weekend crash course in mysql, php

I have verified that I can talk to the DB from php with a mysql_connect that works fine.

if I run php from windows command line and parse the file through I get no syntax errors

I am really stuck with this one - can anyone offer any help please!

The code
----------
<?php

// QueryHandler.php - Query Handler (or title name is Working with Result Sets)
// Accept a query, run it against the inventory
// Database and print the results

// Opens the DB, performs the query and return the results
function doquery($query)
{ // Get rid of the pesky smart quotes
$query = stripsplashes($query);
$db = "inventory";
// Do the query
$link = mysql_connect("","******","******") or die("Could not connect to server! Error: " . mysql_error());
mysql_select_db($db, $link) or die("Could not select ". $db."! Error: ". mysql_error());
$result = mysql_query($query, $link) or $result = "Query Error!<p>Query: ". $query."<p>.Error :" . mysql_error();
mysql_close($link);
// Return the results
return($results);
}

// Parse the result set ($result) into a table
function parseresults($result)
{ // Test for empty result set
// If there is data, do the header (column names) row
if ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{ print "<table border=1 cellpadding=3>\n<tr>";
// Parse the column names
foreach($line as $key => $value)
{ print "<td><b>$key</b></td>\n";
}
print "</tr>\n";
// Reset data pointer
mysql_data_seek($result,0);
// Step through the data rows
while ($line = mysql_fetch_row($result))
{ print "<tr>";
// Print each value in its own cell
Code:
foreach($line as $key => $value)
                                                { print "<td>$line[$key]&nbsp;</td";
                                                }
                                    print "</tr>\n";
                           }
                           print "</table>\n";
                        } else {    // If mysql_fetc_array fails, report empty set
                                       print "Empty Result Set.<p>";
                                  }
                  }
   // Display the form
   function displayform($result)
                  { print "<html>\n<head>\n<title>queryHandler.php</title>\n</head>\n<body>";
                     print "<form action=" . $PHP_SELF . " method=" . $POST . ">\n";
                     print "Enter your query below.  Remember, no semicolon at the end!<p>";
                     print "<input type=\"hidden\" name=\"cmd\" value=\"doquery\">";
                     print "<input type=\"text\" name=\"query\" size=\"80\" value=". $query . "><p>";
                     print "<p><hr>";
                     // Parse the results if $result actually points to a resouce (result set), else just print the value of $result
                     if (is_resource($result))
                           { parseresults($result);
                           } else {
                                       print $result . "<p>\n";
                                     }
                     print "\n<p>\n</form>\n</body>\n</html>";
                   }
                  
   // Main Program body
   // First time through ($cmd <> doquery and no query run), don't run the query
   if ($POST["cmd"] == $doquery)
         {   $query = $_POST["query"];
            if (!$query == "")
                  { $result = doquery($query);
               }
         }
         
   // Display the form (and results for prev query)
   displayform($result);
?>

_________________
Red Alert Sir? You know that would mean changing the lightbulb! (RedDwarf)
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu Mar 16, 2006 5:44 pm    Post subject: Reply with quote

You're obviously not on the correct page then, are you?
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
darrenfinch
-


Joined: 19 Jan 2006
Posts: 6

PostPosted: Thu Mar 16, 2006 10:25 pm    Post subject: Reply with quote

and this means?
_________________
Red Alert Sir? You know that would mean changing the lightbulb! (RedDwarf)
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Mar 16, 2006 10:43 pm    Post subject: Reply with quote

He's basicly saying that you need to read it more because it's not working.
I have a few ebooks if you want some real PHP/MySQL learning.

Note: You can send me an e-mail to trustpunk@gmail.com for an ebook
if you want to learn from an actual book instead of a stupid site tutorial.
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group