[PHP] mysql_select_db error

2004-10-30 Thread Steven James Samuel Stapleton
Relevant information:
Windows XP Pro SP2
PHP 5.0.2
MySQL 4.0.21-nt
command line (not server-side)
mysql_select_db returns no errors, and does not result in a mysql_error(), 
however, later queries result in errors suggesting that the switch failed:


//I'm having problems with mysql_select_db("DBNAME", resource) and
$test = mysql_query("use DBNAME", $resource);
//This results in no errors (I checked to make sure a true value was 
returned,
//and made sure mysql_errno() returned 0).
if(!$test || mysql_errno())
{
 die("Error selecting DB");
}

//next, I'll make a query:
mysql_query("create table foo ( bar int, morebar int )", $resource);
if(mysql_errno())
{
 die(mysql_error());
}
//I get
//No Database Selected

There appear to be quite a few related/similar posts, but I can't find any 
that address this particular variant of the problem, which are solved.

Thanks
-Jim Stapleton 

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


[PHP] Unbuffered Reads

2005-06-05 Thread Steven James Samuel Stapleton
Is there any way to perform an unbuffered read in PHP when reading from 
STDIN?


I.E. if I have the code

-
$chr = "";
while(!feof(STDIN))
{
 $chr = fgetc(STDIN); //I could just as easily do fread(STDIN, 1)
 if($chr == " ")
   break;
}
-

and enter the following string (note this is how you would enter the string 
in a program to have it have the same value I'd type in):

"this is a test\n"

It will stop reading at the newline, and not the first space.

Any ideas?


System Info
Environment: Windows XP Pro (used both the windows and cygwin command lines)
PHP Version: 5.0.3

Thanks
-Jim Stapleton 


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