You are here: Re: Help, can't select?? « PHP Language « IT news, forums, messages
Re: Help, can't select??

Posted by Richard on 07/01/07 13:48

"masterx" <masterx@anonymous.org> wrote in message
news:138e0scthj3co13@corp.supernews.com...
> masterx wrote:
>> Richard wrote:
>>> "masterx" <masterx@anonymous.org> wrote in message
>>> news:138duk2642c7pf8@corp.supernews.com...
>>>> Hey guys, I'm having issues with some MySQL code in PHP. I'm running
>>>> MySQL-nt 3.23.38, PHP 4.4.1 and Apache 2.0.55 under Windows XP SP2. I'm
>>>> just running these as my local development platform.
>>>>
>>>> I've been using this DB for some time now without any problems, until
>>>> recently when I needed to add a couple of new tables. I've added the
>>>> tables fine (they are the same type as all the other tables in the DB)
>>>> but I can not select the new tables in PHP. It's the exact same code
>>>> I've used to fetch data from the older tables but it just won't do it
>>>> for the new tables... I'm pulling my hair out. ;-)
>>>>
>>>> Examples...
>>>>
>>>> //old (working) code:
>>>> $query = "SELECT * FROM brokers";
>>>> $result = mysql_query($query);
>>>> $num_rows = mysql_num_rows($result);
>>>>
>>>>
>>>> //new code:
>>>> $query = "SELECT * FROM locations";
>>>> $result = mysql_query($query);
>>>> $num_rows = mysql_num_rows($result);
>>>>
>>>> I've also tried
>>>> $result = mysql_query("SELECT * FROM cities");
>>>> instead of using $query var, same result. The new query returns false
>>>> for some reason. What makes me think it's a PHP problem is that I can
>>>> run MySQLFront and run the exact same query just fine and fetch the
>>>> data, it all seems to work fine outside of PHP. Is my version of PHP a
>>>> little screwy? Maybe needs updating? Any ideas?
>>>>
>>>> Thanks.
>>>
>>> Check the error message that is returned, that will give you (and us)
>>> more clues....
>>>
>>> Richard
>>>
>>
>> Sorry, no actual errors are reported (even after setting
>> error_reporting(E_ALL);) the query simply returns false and I get two
>> warnings about the invalid mysql result resource when I try to use
>> $result...
>>
>> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
>> resource in D:\Apache\Apache2\htdocs\NewNationwide\nwl\nwadmin.php on
>> line 473
>>
>> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
>> result resource in D:\Apache\Apache2\htdocs\NewNationwide\nwl\nwadmin.php
>> on line 476
>
> I sorted it out, sorry, it turned out to be one of those brain fade
> occasions... I created the tables in the wrong DB... idiot!!! :P
> Note to self: delete old DB's that you no longer use and have similar
> names to your active DB's! Thanks anyway.

Well... ok, but
if your query fails, then you want to know why.
As "rf" pointed out, use

echo mysql_error();

when query returns false.

Richard

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация