Re: Help Me Please ... it's urgent !!
| From: | Tom | Date: | Tue, 12 Dec 2000 10:13:21 +0000 |
| Subject: | Re: Help Me Please ... it's urgent !! | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-4419@lists.php.net to get a copy of this message | ||
Two suggestions: -
1) To solve your problem, instead of using
if ($comp)...
try: -
if (isset($comp))
(and if you want it to occur only if $comp is non-zero then put an AND condition in for this).
The error is occuriing because you're performing a check on a variable that may not yet exist!
2) This will probably sound critical, but its not intended that way! If you use style sheets instead
of keeping all the colour information, size, alignment etc in the script, then your code will be a
lot easier to follow, smaller and faster!
Tom
DEWA wrote:
> Hi ...
>
> My name is Dedy Wahyudi ...
>
> I follow your instruction at webmonkey site regarding PHP/MySQL Tutorial ..
>
> But there is some problem i'm having ... may be you can tell me ....
>
> <?
> $connect= mysql_connect("localhost","root")
> or die ("Can not established a connection to Localhost !!!");
> mysql_select_db ("data");
> if ($comp) {
> $cari="SELECT * FROM admin WHERE company=$comp";
> $hasil=mysql_query($cari);
> while ($row=mysql_fetch_array($hasil)) {
> print "<tr><td valign='top' nowrap colspan='5'><font
> size='2'></font><font size='2'></font><font
> size='2'></font><font size='2'></font><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top'
> nowrap> </td><td width='153' valign='top' nowrap
> bgcolor='#33CCCC'><font size='2'> <b>Type of
> Service</b></font></td><td width='10' valign='top' nowrap
> bgcolor='#33CCCC'><div align='center'><font
> size='2'><b>:</b></font></div></td><td
> width='277' valign='top'
> bgcolor='#33CCCC'><b>".$row['type']."</b></td><td
> width='5' valign='top' nowrap> </td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font size='2'> Company
> Name</font></h3></td><td width='10' valign='top' nowrap
> bgcolor='#33CCCC'><h3 align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['company']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font size='2'> Contact
> Person</font></h3></td><td width='10' valign='top' nowrap
> bgcolor='#33CCCC'><h3 align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['person']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Title</font></h3></td><td width='10'
> valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['title']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Department</font></h3></td><td
> width='10' valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['dept']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Phone</font></h3></td><td width='10'
> valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['phone']."</b>
> Ext. <b>".$row['ext']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Fax</font></h3></td><td width='10'
> valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['fax']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font size='2'> Cellular
> Phone</font></h3></td><td width='10' valign='top' nowrap
> bgcolor='#33CCCC'><h3 align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><font
> size='2'><b>".$row['cel']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Address</font></h3></td><td
> width='10' valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'><p><font
> size='2'><b>".$row['address1']."</b><br><b>".$row['address2']."</b><br></font></p></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> City</font></h3></td><td width='10'
> valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'> <font
> size='2'><b>".$row['city']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Postcode</font></h3></td><td
> width='10' valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'> <font
> size='2'><b>".$row['post']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font size='2'> E-Mail
> Address</font></h3></td><td width='10' valign='top' nowrap
> bgcolor='#33CCCC'><h3 align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'> <font
> size='2'><b>".$row['email']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> print "<tr><td width='5' valign='top' nowrap><font
> size='2'></font></td><td width='153' valign='top'
> nowrap bgcolor='#33CCCC'><h3><font
> size='2'> Note</font></h3></td><td width='10'
> valign='top' nowrap bgcolor='#33CCCC'><h3
> align='center'><font
> size='2'>:</font></h3></td><td width='277'
> valign='top' bgcolor='#33CCCC'> <font
> size='2'><b>".$row['note']."</b></font></td><td
> width='5' valign='top' nowrap><font
> size='2'></font></td></tr>";
> }
> }
> else {
> $query = "SELECT company FROM admin WHERE TYPE='IWL/IDL'";
> $result = mysql_query($query);
> echo "<form name='jumpiwl2'>";
> echo "<select name='comp'
> onChange='MM_jumpMenu('self',this,0)' size='1'>";
> echo "<option selected >-- Choose the Company --</option>";
> while ($rows = mysql_fetch_array($result)) {
> printf ("<option value=\"%s?comp=%s \">%s</option>", $PHP_SELF,
> $rows["company"], $rows["company"]);
> }
> echo "</select>";
> echo "</form>";
> }
> ?>
>
> Whenever i run this script, it always said that :
>
> Warning: Undefined variable: comp in c:\homepage\viewadmiwl.php on line 28
>
> which is mean that variable $comp is not recognize ...
>
> Could you tell me what when wrong ??? coz I really need this thing working as soon as possible
> ...
>
> Thank you very much for your attention ..
>
> Regards,
>
> Dedy Wahyudi