Hello all,

I am very new to php, in fact, this is my first attempt at a script.  I have
just been following a tutorial online.  Currently, I have a page where the
user types in a username and password, I then pass those parameters to this
page.  This page connects to a main db, looks up their username and password
and then attempts to switch them to their own db but that doesn't seem to
work.  When the page loads, I get errors because of my last select.  It
tells me that the database users does not have a table grades which is true
but I wanted it to change to the grades db.  How can I fix this?

Also-is there a way in php to display the results of a query into an
editable grid?

Thanks,
Eddie



<html>
 <head>
  <title>PHP Test</title>
 </head>
<body bgcolor="white">


<?php
// connect to db
 $dbcnx=mysql_connect("localhost","user","password");
 if (!$dbcnx) {echo ("<p>Unable to connect to the database server at this
time");
               exit();
           }

  // use the users db
 mysql_select_db("users", $dbcnx);
  if (! @mysql_select_db("users"))
      { echo ("Unable to connect to the main db at this");
       exit();
          }


  $result=@mysql_query("Select dbname from users where pword='$password' and
username='$username'");
   // if (!$result) {
   //                echo("<p>Error performing query: " . mysql_error() .
   //                     "</p>");
   //                exit();
   //               }
   //($row=mysql_fetch_array($result))




mysql_select_db("grades",$dbcnx);


 $result=@mysql_query("Select subject, grade from grades");
    if (!$result) {
                   echo("<p>Error performing query: " . mysql_error() .
                        "</p>");
                   exit();
                  }
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["Grades"] . "</p>");
 }


?>
</blockquote>
</body>
</html>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to