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:
  #1  
Old July 26th, 2002, 07: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, 09: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: 3
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, 04: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, 06: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: 3
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, 07: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: 3
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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek