Re: newbie mysql and php
| From: | tony | Date: | Sun, 28 Dec 2003 10:24:24 +0000 |
| Subject: | Re: newbie mysql and php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173395@lists.php.net to get a copy of this message | ||
the problem i get is that its say no database selected
Anthony
"Chris" <chris@leftbrained.org> wrote in message
news:JCEBKEIIBIOHLMACLNFDIEECCKAA.chris@leftbrained.org...
> It looks like mysql_query is failing, add these two lines to your code,
and
> see what message pops up:
>
> ...
> $dbdo = mysql_query($query,$dbconnect);
> if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
> else echo 'The query worked, $dbdo value is:',$dbdo;
> while($row= mysql_fetch_array($dbdo)){
> ...
>
>
> Chris
>
> -----Original Message-----
> From: tony [mailto:awardd@essex.ac.uk]
> Sent: Saturday, December 27, 2003 4:18 PM
> To: php-general@lists.php.net
> Subject: [PHP] newbie mysql and php
>
>
> hello
>
> I'm new with php just learning and i have just a problem with the
following
> code
>
> $dbconnect = mysql_connect("localhost", "prog_tony","PASSWORD");
> mysql_select_db("prog_dealer", $dbconnect);
> $stop = 0;
> $counter = 1;
> while(!$stop){
> $query = "SELECT name FROM category WHERE id = $counter";
> $dbdo = mysql_query($query,$dbconnect);
> while($row= mysql_fetch_array($dbdo)){
> if($row[0]){
> $counter++;
> }else{
> $stop=1;
> }
> $row[0] = "";
> }
>
> }
>
>
>
> I'm getting an error with mysql_fetch_array() which is line 14 because I
> didn't show the other lines since it is not relevant.
> here is the error
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result
> resource in /home/prog/public_html/php/cateadded.php on line 14
>
> Thank you
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php