Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 26th, 2002, 06:45 AM
notbad notbad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sunshine Coast, Qld, Australia
Posts: 3 notbad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to notbad
So simple but just won't work

I just can't work out why this code:

<html>
<body>
<?PHP
$data_b = mysql_pconnect("dbs.server","root","");
mysql_select_db("databasename");
$query = "SELECT office_id, contact,site,street_add,Postal_add,city,state,pcod e,phone,fax,email,website FROM office_table WHERE site = ";
$query .= $HTTP_GET_VARS['of0'];
$result = mysql_query($query);
$row = mysql_fetch_array($result);
?>
<? PHP echo $row['contact'] ?>
</body>
</html>

Is giving me this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/htdocs/notbad/docs/Eplus_Beta/NSW/stationery2.php on line 4

If you can help it will make me very happy.


Reply With Quote
  #2  
Old July 26th, 2002, 08:01 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: So simple but just won't work

That error message is telling you that your query is wrong, either improperly formated, fields dont exist, etc.

The problem with your query is that there are no quotes around what site is suppose to be equal to. I find it helpful prior to putting my queries in code, I like to run them in my mysql client first. This way I see the result set and can verify that it returns what I wanted. You can test it by doing this:
mysql -u username -p dbname

One wat to fix your syntax problem is to use a query like this:
php Code:
Original - php Code
  1. $query = "SELECT office_id, contact,site,street_add,Postal_add,city,state,pcod  e,phone,fax,email,website FROM office_table WHERE site='".$HTTP_GET_VARS['of0']."'";


Hopoe that helps.

Reply With Quote
  #3  
Old August 3rd, 2002, 03:54 PM
notbad notbad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sunshine Coast, Qld, Australia
Posts: 3 notbad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to notbad
RE: So simple but just won't work

it seems that "$row = mysql_fetch_array($result); " has to be used as an argument like "if ($row = mysql_fetch_array($result)) { etc."
It's the only way I can assign the values to the array. I don't know why but it works.

Reply With Quote
  #4  
Old August 3rd, 2002, 05:32 PM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: So simple but just won't work

hmmm...

Very strange! I use code like this and it works fine:

$query = "select sount(*) from table";
$result = mysql_query($query);
$row = mysql_fetch_array($result);

Wierd.

Reply With Quote
  #5  
Old August 3rd, 2002, 06:02 PM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: So simple but just won't work

Let me rewrite that:

$query = "select count(*) as total from members";
$result = mysql_query($query);
$row = mysql_fetch_array($result);

echo "There are ".$row['total']." registered members";

Thats better.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > So simple but just won't work


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway