Re[2]: [PHP] ASP to PHP language problems

From: Date: Thu, 11 Mar 2004 01:44:03 +0000
Subject: Re[2]: [PHP] ASP to PHP language problems
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-180084@lists.php.net to get a copy of this message
Hello Alistair, Thursday, March 11, 2004, 1:25:47 AM, you wrote: AH> <?php AH> unset($type); AH> $type = $_GET['type']; AH> $link = mysql_connect('localhost', 'user', 'password'); AH> if (!$link) { AH> echo "Couldn't make a connection!"; AH> exit; AH> } AH> $db = mysql_select_db("sealhouse", $link); AH> if (!$db) { AH> echo "Couldn't select database!"; AH> exit; AH> } AH> $sql= "SELECT * FROM table WHERE type=$type ORDER BY style"; AH> $result = mysql_query($sql); AH> $total_records = mysql_num_rows($result); Try and put single quotes around the $type in your query. Especially if it's not numeric: $sql = "SELECT blah WHERE type='$type'"; Otherwise, the code is fine. So assuming the database exists and the query is valid (i.e. works from MySQL itself) then it should work. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#180084) next »