The error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/rvathete/public_html/vdf/vdf.php on line 39
Line 39 is thhe fetch array; $data is defined in each conditional; however, is stating that the array is not defined; not sure if this is an improper method or i’ve been pounding away for too long…
code:
[php]<?php
$link = mysql_connect(“localhost”,“rvathete_test”,“vdftest”);
if (!link)
{die('Could not connect: ’ . mysql_error());}
mysql_select_db(“rvathete_test”, $link);
$lname = $_GET[‘Lastname’];
$fname = $_GET[‘firstname’];
$rank = $_GET[‘rank’];
// method one
if (isset($_GET[‘Lastname’])) {
if (empty($_GET[‘rank’]) && (empty($_GET[‘firstname’]))) {$data = (“SELECT * FROM test1 WHERE Lastname LIKE ‘$lname%’”);}
if (empty($_GET[‘rank’]) && (isset($_GET[‘firstname’]))) {$data = (“SELECT * FROM test1 WHERE Lastname LIKE ‘$lname%’ AND firstname LIKE ‘$lname%’”);}
if (empty($_GET[‘firstname’]) && (isset($_GET[‘rank’]))) {$data = (“SELECT * FROM test1 WHERE Lastname LIKE ‘$lname%’ AND rank LIKE ‘$rank%’”);}
if (isset($_GET[‘firstname’]) && (isset($_GET[‘rank’]))) {$data = (“SELECT * FROM test1 WHERE Lastname LIKE ‘$lname%’ AND rank LIKE ‘$rank%’ AND firstname LIKE ‘$fname%’”);}
}
if (isset($_GET[‘rank’])) {
if (empty($_GET[‘firstname’]) && (empty($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE rank LIKE ‘$rank%’”);}
if (empty($_GET[‘firstname’]) && (isset($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE rank LIKE ‘$rank%’ AND Lastname LIKE ‘$lname%’”);}
if (empty($_GET[‘Lastname’]) && (isset($_GET[‘firstname’]))) {$data = (“SELECT * FROM test1 WHERE rank LIKE ‘$rank%’ AND firstname LIKE ‘$fname%’”);} if (isset($_GET[‘firstname’]) && (isset($_GET[‘Lastname’]))) {(“SELECT * FROM test1 WHERE Lastname LIKE ‘$lname%’ AND rank LIKE ‘$rank%’ AND firstname LIKE ‘$fname%’”);}}
if (isset($_GET[‘firstname’])) {
if (empty($_GET[‘rank’]) && (empty($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE firstname LIKE ‘$fname%’”);}
if (empty($_GET[‘rank’]) && (isset($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE firstname LIKE ‘$fname%’ AND Lastname LIKE ‘$Lname%’”);}
if (isset($_GET[‘rank’]) && (empty($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE firstname LIKE ‘$fname%’ AND rank LIKE ‘$rank%’”);}
if (isset($_GET[‘firstname’]) && (isset($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE Lastname LIKE ‘$lname%’ AND rank LIKE ‘$rank%’ AND firstname LIKE ‘$fname%’”);}}
if (isset($_GET[‘rank’])) {
if (empty($_GET[‘firstname’]) && (empty($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE rank LIKE ‘$rank%’”);}
if (empty($_GET[‘firstname’]) && (isset($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1 WHERE rank LIKE ‘$rank%’ AND Lastname LIKE ‘$lname%’”);}
if (empty($_GET[‘Lastname’]) && (isset($_GET[‘firstname’]))) {$data = (“SELECT * FROM test1 WHERE rank LIKE ‘$rank%’ AND firstname LIKE ‘$fname%’”);}
if (isset($_GET[‘firstname’]) && (isset($_GET[‘Lastname’]))) {$data = (“SELECT * FROM test1”);}}
if (empty($_GET[‘Lastname’])) {
if (empty($_GET[‘firstname’]) && (empty($_GET[‘rank’]))) {$data = (“SELECT * FROM test1”);}}
Print “
Last Name | First Name | Rank |
”; while ($info = mysql_fetch_array($data) or die(mysql_error())) { Print $info[‘Lastname’]. “ |
”. $info[‘firstname’]. “ | ”. $info[‘rank’]. “ |
”; } Print “ |
mysql_close($link);
?>[/php]