Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

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 Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2001, 03:33 AM
phyzar phyzar is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Syd or UK
Posts: 21 phyzar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 21 sec
Reputation Power: 0
Send a message via ICQ to phyzar
php amateur...

Guys, help us out here please...
-----------------------------------
the script...
-----------------------------------
<html>
<body>
<?php
require("mydb.inc");

mysql_connect("***.**.***.**",$user,$password);

$database="ellel";
@mysql_select_db("$database") or die( "Unable to select database");

$sql = "SELECT company_name,link_ref,region FROM advertisers WHERE region='";


//switch loop
switch ($select){

//scotland search
case 1:
$sql .= "Scotland'";
break;

//north england search
case 2:
$sql .= "North England'";
break;

//central england search
case 3:
$sql .= "Central England'";
break;

//wales search
case 4:
$sql .= "Wales'";
break;

//south east england search
case 5:
$sql .= "South East England'";
break;

//south west england search
case 6:
$sql .= "South West England'";
break;

//channel islands search
case 7:
$sql .= "Channel Islands'";
break;

//northern ireland search
case 8:
$sql .= "North Ireland'";
break;

//ireland search
case 9:
$sql .= "Ireland'";
break;

//overseas search
case 10:
$sql .= "Overseas'";
break;

//all search
//case 11
//$sql .= "%'";
//break;
}


$query=mysql_query($sql);

$rslt=mysql_fetch_array($query);

//display results

echo "<table>\n<tr>\n";
echo "<td>Company Name</td>\n";
echo "<td>URL</td>\n";
echo "<td>Region</td>\n";
echo "</tr>\n";

while ($row = mysql_fetch_array($query)) { // or list($all, $the, $retrieved, $columns)
echo "<tr>\n";
echo "<td>$row[company_name]</td>\n";
echo "<td>$row[link_ref]</td>\n";
echo "<td>$row[region]</td>\n";
echo "</tr>\n";
}
echo "</table>\n";


?>
</body>
</html>
-----------------------------------
returns...
-----------------------------------
Warning: Supplied argument is not a valid MySQL result resource in /home/christianh/public_html/out3.php on line 76

Warning: Supplied argument is not a valid MySQL result resource in /home/christianh/public_html/out3.php on line 86

Company Name URL Region

-----------------------------------
HELP?? i cant pick anything wrong with this current syntax...
much appreciated
JD

Reply With Quote
  #2  
Old June 1st, 2001, 04:45 PM
Theeggman Theeggman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 266 Theeggman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 33 sec
Reputation Power: 8
Keep in mind I am fairly new to php as well. But I will give it a shot.

The first thing is it is not your php but your MYSQL queries which are failing.

$sql = "SELECT company_name,link_ref,region FROM advertisers WHERE region='";

There are no () around your query plus in the section "WHERE region = '"; it looks like you only have one ' instead of ' '

$sql = ("SELECT company_name,link_ref,region FROM advertisers WHERE region=''";

I hope that helps

E.

Reply With Quote
  #3  
Old June 1st, 2001, 05:14 PM
undodigital undodigital is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 1 undodigital User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm new to php also, but i think this will work:

echo "<td>" . $row["company_name"] . "</td>\n";
echo "<td>" . $row["link_ref"] . "</td>\n";
echo "<td>" . $row["region"] . "</td>\n";


I hope this helps.

Last edited by undodigital : June 2nd, 2001 at 01:23 PM.

Reply With Quote
  #4  
Old June 10th, 2001, 03:38 PM
bombel bombel is offline
,-)
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Location: Germany
Posts: 13 bombel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
theeggman should be right - almost...

don't need brackets around your query, but supplied argument is missing (or misspeled), thats the key.

try:

//switch loop
switch ($select){

//scotland search
case 1:
$selection="Scotland";
break;

and so on...

$sql = "SELECT company_name,link_ref,region FROM advertisers WHERE region='$selection'";

should be easier with the variable rather than adding something to the querystring



bombel

problem solved already?

just post a "worked" or something so no one bothers with your questions anymore

Last edited by bombel : June 10th, 2001 at 03:43 PM.

Reply With Quote
  #5  
Old June 11th, 2001, 04:39 AM
phyzar phyzar is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Syd or UK
Posts: 21 phyzar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 21 sec
Reputation Power: 0
Send a message via ICQ to phyzar
working, thanx all

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > php amateur...


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


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





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