Jump to content

Pikachu2000

Staff Alumni
  • Posts

    11,377
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Pikachu2000

  1. You can't use solely PHP to perform any form validation without submitting the form. PHP, as you know, is a server side language. Make the form fields sticky, and validate it all at once, using header() to redirect to a success page if submitted with no errors, or redisplay the form with the errors highlighted (if there are errors) or if the username is unavailable.

  2. It is a mysql connect object.

     

    If it's just the database name, it should work in the query, if it is a

    $mydb = mysql_connect( $db_host, $db_user, $db_pass ); 

    statement, it will not. That means you will have to use a variable containing only the database name. Try echoing the $sql variable to see what you are sending as a db query.

  3. Thanks

     

    Everytime I try it I get a mydb could not be  converted to string.

    		$sql = "SHOW TABLES FROM $mydb" or die (mysql_error());
    		$result = mysql_query($sql);
    
    		while ($row = mysql_fetch_row($result)) {
    		    echo "Table: {$row[1]}\n";
    		}

     

    Assuming you have the $mydb variable's value set elsewhere, this should work for you.

     

    $query = "SHOW TABLES FROM " . $mydb;
    $result = mysql_query( $query );
    while( $array = mysql_fetch_array( $result, MYSQL_ASSOC) )
    {
    print_r( $array );
    }
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.