[thelist] mysql_query + php

Andrew andrew at humanbehaviour.co.uk
Tue Mar 4 06:57:05 CST 2003

Thanks Jon that was avery helpful and a great tip too

>-----Original Message-----
>From: thelist-admin at lists.evolt.org
>[mailto:thelist-admin at lists.evolt.org]On Behalf Of Jon Haworth
>Sent: 25 February 2003 09:21
>To: 'thelist at lists.evolt.org'
>Subject: RE: [thelist] mysql_query + php
>Hi Andrew,
>> can anone say why this doesn't work?
>> $result=mysql_query("$DBName","SELECT City, CityID
>> FROM city ORDER BY City");
>You should pass the query as the first parameter:
>$result = mysql_query("SELECT City, CityID FROM city ORDER BY City");
>I don't think you need the other parameter unless you have two database
>connections open at once and you want to distinguish between them.
>Also, if you don't mind an additional comment that'll save you some pain
>later: rather than referring to the rows by number:
>> echo "<option value=\"$row[1]\"> $row[0] </option>";
>refer to them by name, like this:
>echo $row["CityID"];
>This will save you a couple of hours of debugging when you change the query
>to select different fields :-)
>* * Please support the community that supports you.  * *
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.456 / Virus Database: 256 - Release Date: 18/02/2003

More information about the thelist mailing list