Hmm, I trried your syntax and same problem.  

I tried it exactly like this:  (though i'd like to stress that it worked with the code 
labeled ORIGINAL below)


<?php


$connection = mysql_connect("********","*****","*********")
or die("Couldn't make connection...because I hate you.");


$db = mysql_select_db("national", $connection)
or die("Couldn't select database.");


$sql = "SELECT * FROM accessnums WHERE areacode='{$_POST['areacode']}' and
city='{$_POST['cityselected']}' ORDER BY network LIMIT 1";


// ORIGINAL $sql = "SELECT * FROM accessnums WHERE areacode='$_POST[areacode]' and 
city='$_POST[cityselected]' ORDER BY network LIMIT 1";

//  WORKS just needs tweaking: SELECT * FROM accessnums WHERE areacode="318" and 
city="monroe" ORDER BY network LIMIT 1;


$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute query.");
   

while ($row = mysql_fetch_array($sql_result)) {

$network = $row["network"];
$areacode = $row["areacode"];
$cityselected = $row["cityselected"];

}



if ($network == 1):
    echo "<p>This customer is on network: <font size=\"4\">A</font>.  This is Bayou 
Internet's network.<br>They should  download Dialer A at: <a href=
\"http://www.bayou.com/dialer/dialer.exe\";>http://www.bayou.com/dialer/dialer.exe</a></p>";
elseif ($network == 2):
    echo "<p>This customer is on network: <font size=\"4\">B</font>.  This is 
Surf.net's network.<br>They should download Dialer B at: <a 
href=\"http://www.bayou.com/dialer/dialer-b.exe\";>
http://www.bayou.com/dialer/dialer-b.exe</a></p>";
elseif ($network == 3):
    echo "<p>This customer is on network: <font size=\"4\">B</font>.  This is 
Surf.net's network.<br>They should download Dialer B at: <a 
href=\"http://www.bayou.com/dialer/dialer-b.exe\";>
http://www.bayou.com/dialer/dialer-b.exe</a></p>";
elseif ($network == 4):
    echo "<p>This customer is on network: <font size=\"4\">E</font>.  This is Dual.usa 
/ @usa's network.<br>They  should download Dialer E at: <a 
href=\"http://www.bayou.com/dialer/dialer-
e.exe\">http://www.bayou.com/dialer/dialer-e.exe</a></p>";
elseif ($network == 5):
    echo "<p>This customer is on network: <font size=\"4\">C</font>.  This is 
Pop.net's network.<br>They should download Dialer C at: <a 
href=\"http://www.bayou.com/dialer/dialer-c.exe\";>
http://www.bayou.com/dialer/dialer-c.exe</a></p>";
elseif ($network == 6):
    echo "<p>This customer is on network: <font size=\"4\">D</font>.  This is 
World.net's network.<br>They should download Dialer D at: <a 
href=\"http://www.bayou.com/dialer/dialer-d.exe\";>
http://www.bayou.com/dialer/dialer-d.exe</a></p>";
else:
    echo "There has been a data error.  This is most likely the programmer's fault.  
Blame funding.  <a href=\"http://www.bayou.com/dialer/admin/numbercheck.php\";>Ignore 
and try again.</a>";
endif;


mysql_free_result($sql_result);
mysql_close($connection);

?>











1/30/2003 3:51:15 PM, "Ignatius Reilly" <[EMAIL PROTECTED]> wrote:

>Doubly wrong PHP syntax.
>
>Try instead:
>$sql = "SELECT * FROM accessnums WHERE areacode='{$_POST['areacode']}' and
>city='{$_POST['cityselected']}' ORDER BY network LIMIT 1";
>
>Ignatius
>____________________________________________
>----- Original Message -----
>From: "jason wesley upton" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Thursday, January 30, 2003 9:42 PM
>Subject: [PHP-DB] SQL: Limit 1 usage?
>
>
>> Currently I have a script that contains this piece of code:
>>
>>
>> $sql = "SELECT MIN(network)
>> AS 'network' FROM accessnums WHERE areacode='$_POST[areacode]' and
>city='$_POST[cityselected]'";
>>
>>
>> This works fine and accomplishes what I need.  Some requirements changed
>today and I now need to get more than just "network".  In MySQL command line
>I tried this:
>>
>> SELECT * FROM accessnums WHERE areacode="504" and city="New Orleans" ORDER
>BY network LIMIT 1;
>>
>> This gives me the exact response I require.  However, when plugging it
>into my php code:
>>
>> $sql = "SELECT * FROM accessnums WHERE areacode=$_POST[areacode]' and
>city='$_POST[cityselected]' ORDER BY network LIMIT 1";
>>
>> It can't execute the query.  Any suggestions?
>>
>>
>>
>>
>> Jason Wesley Upton - Web Design / Development - Application Development









-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to