livegirllove
asked on
Return Message if id number not found
How do I tell php/mysql to return a different message if the id number entered is not in the table? Here is the script I'm using:
<form action="" method="POST">
<input type="text" name="serviceid" >
<input type="submit" name="submit" value="Get Your Drivers">
<input type="hidden" name="submit" value="Submit Service Tag Number">
</form>
<p class="newsbody"> </p ></td>
<td width="55%" class="contactform"><div align="center"> <img src="../images/servicecode pic1.jpg" width="320" height="240"><br>
<span class="google">(usually located on the bottom of your computer)</span></div></td >
</tr>
</table>
<p> </p>
<p> </p>
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid' AND drivers.id IN(servicetag.mb, servicetag.vid, servicetag.lan, servicetag.sound, servicetag.modem, servicetag.scsi, servicetag.other1, servicetag.other2, servicetag.other3, servicetag.other4)";
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
print "<table><tr><th>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</th></tr>";
while($row = mysql_fetch_assoc($res_cat )) { // fetch the row
print "<tr><td>\n<p><a href=\"{$row['link']}\">{$ row['name' ]}</a></p> \n</td></t r>\n";
}
print "</table>";
}
?>
<form action="" method="POST">
<input type="text" name="serviceid" >
<input type="submit" name="submit" value="Get Your Drivers">
<input type="hidden" name="submit" value="Submit Service Tag Number">
</form>
<p class="newsbody"> </p
<td width="55%" class="contactform"><div align="center"> <img src="../images/servicecode
<span class="google">(usually located on the bottom of your computer)</span></div></td
</tr>
</table>
<p> </p>
<p> </p>
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid'
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
print "<table><tr><th>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</th></tr>";
while($row = mysql_fetch_assoc($res_cat
print "<tr><td>\n<p><a href=\"{$row['link']}\">{$
}
print "</table>";
}
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thasmartuno- your solution gives this error on any query.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/soloen te/support .solohelp. com/index. php on line 114
no category.
Here is the code:
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid' AND drivers.id IN(servicetag.mb, servicetag.vid, servicetag.lan, servicetag.sound, servicetag.modem, servicetag.scsi, servicetag.other1, servicetag.other2, servicetag.other3, servicetag.other4)";
if (mysql_num_rows($res_cat) < 1) {
echo "no category.";
} else {
// continue with the rest.
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
print "<table><tr><th>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</th></tr>";
while($row = mysql_fetch_assoc($res_cat )) { // fetch the row
print "<tr><td>\n<p><a href=\"{$row['link']}\">{$ row['name' ]}</a></p> \n</td></t r>\n";
}
print "</table>";
}
}
?>
************************** ********** ********** ********** ********** *********
Squinky-
Long time no see ;-)
Parse error: parse error in /hsphere/local/home/soloen te/support .solohelp. com/index. php on line 149
Line 149 is the last line in the page. </html>
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid' AND drivers.id IN(servicetag.mb, servicetag.vid, servicetag.lan, servicetag.sound, servicetag.modem, servicetag.scsi, servicetag.other1, servicetag.other2, servicetag.other3, servicetag.other4)";
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
if (mysql_num_rows($res_cat) >= 1) {
print "<table><tr><th>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</th></tr>";
while($row = mysql_fetch_assoc($res_cat )) { // fetch the row
print "<tr><td>\n<p><a href=\"{$row['link']}\">{$ row['name' ]}</a></p> \n</td></t r>\n";
}
print "</table>";
} else {
print "<p>no drivers found for service tag $serviceid</p>\n";
}?>
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/soloen
no category.
Here is the code:
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid'
if (mysql_num_rows($res_cat) < 1) {
echo "no category.";
} else {
// continue with the rest.
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
print "<table><tr><th>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</th></tr>";
while($row = mysql_fetch_assoc($res_cat
print "<tr><td>\n<p><a href=\"{$row['link']}\">{$
}
print "</table>";
}
}
?>
**************************
Squinky-
Long time no see ;-)
Parse error: parse error in /hsphere/local/home/soloen
Line 149 is the last line in the page. </html>
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid'
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
if (mysql_num_rows($res_cat) >= 1) {
print "<table><tr><th>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</th></tr>";
while($row = mysql_fetch_assoc($res_cat
print "<tr><td>\n<p><a href=\"{$row['link']}\">{$
}
print "</table>";
} else {
print "<p>no drivers found for service tag $serviceid</p>\n";
}?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the help.
For anyone that sees this later.....
<form action="index.php#anch" method="POST">
<input type="text" name="serviceid" >
<input type="submit" name="submit" value="Get Your Drivers">
<input type="hidden" name="submit" value="Submit Service Tag Number">
</form>
<p class="newsbody"> </p ></td>
<td width="55%" valign="top" class="contactform"><div align="center"><a name="anch"></a><img src="http://www.soloenterprises.org/images/servicecodepic1.jpg" width="320" height="240"><br>
<span class="google">(usually located on the bottom of your computer)</span></div></td >
</tr>
</table>
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid' AND drivers.id IN(servicetag.mb, servicetag.vid, servicetag.lan, servicetag.sound, servicetag.modem, servicetag.scsi, servicetag.other1, servicetag.other2, servicetag.other3, servicetag.other4)";
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
if (mysql_num_rows($res_cat) < 1) {
echo "<h3>Sorry <font color=\"red\">$serviceid</ font> Could Not Be Found. <br> Please Check the Service Code and Try Again<br>If that fails Please call ****** 5536</h3>";
} else {
// continue with the rest.
print "<table><tr><td width=\"50%\" valign=\"top\"><h3>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</h3></td><td>";
while($row = mysql_fetch_assoc($res_cat )) { // fetch the row
print "<p class=\"newsbody\"><a href=\"{$row['link']}\">{$ row['name' ]}</a><br> ";
}
print "</p></td></tr></table>";
}
}
?></td>
For anyone that sees this later.....
<form action="index.php#anch" method="POST">
<input type="text" name="serviceid" >
<input type="submit" name="submit" value="Get Your Drivers">
<input type="hidden" name="submit" value="Submit Service Tag Number">
</form>
<p class="newsbody"> </p
<td width="55%" valign="top" class="contactform"><div align="center"><a name="anch"></a><img src="http://www.soloenterprises.org/images/servicecodepic1.jpg" width="320" height="240"><br>
<span class="google">(usually located on the bottom of your computer)</span></div></td
</tr>
</table>
<?php
if (!empty($_POST)) { // form is subitted
include("db.php"); // setup connection to mysql
$sql = "SELECT drivers.id, drivers.name, drivers.link, drivers.cat FROM servicetag, drivers WHERE servicetag.id='$serviceid'
$res_cat = mysql_query($sql) or die(mysql_error()); // handle to category set
if (mysql_num_rows($res_cat) < 1) {
echo "<h3>Sorry <font color=\"red\">$serviceid</
} else {
// continue with the rest.
print "<table><tr><td width=\"50%\" valign=\"top\"><h3>Here Are Your Drivers and any Software Packages that came with your <br>";
print "Custom SOLOHelp.com Computer</h3></td><td>";
while($row = mysql_fetch_assoc($res_cat
print "<p class=\"newsbody\"><a href=\"{$row['link']}\">{$
}
print "</p></td></tr></table>";
}
}
?></td>
if (mysql_num_rows($res_cat) < 1) {
echo "no category.";
} else {
// continue with the rest.
}