Jump to content

Trouble 'notice: Undefined Offset: 1 In ...' Error


ruthpast

Recommended Posts

I find many ways to try to resolve, but no way to success who can teach how to modify the problem

Notice: Undefined offset: 1 inD:\xampp\htdocs\keyword.phpon line 82

<?php
$result=mysql_query("select * from a",$db);
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
while ($rec=mysql_fetch_array($result)) {
$k="$rec[keyword]";
$loc="$rec[location]";
list($k1,$k2) = preg_split("/[\s,]+/", $k);
if ($k1==$k) $key="$k1-$loc";
else $key="$k1-$k2-$loc";
echo "<tr><td>";
echo " <a href='search.php?$k' target='mainFrame'>$rec[keyword]</a>";
echo "</td></tr>";
}
echo "</table>";
?>

You only gave us 15 lines, how are we supposed to know which line is 82?

 

Additionally, associative arrays are called like this

$k=$rec['keyword'];

with single quotes.

 

Lastly, please use our code tags for code.

I'm sorry I did not clearly marked

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>SILK I</title>
<style type="text/css">
<!--
body,td,th {font-size: 12pt;
font-family: Arial, Helvetica, sans-serif;
}
.style1 {font-family: Arial, Helvetica, sans-serif;
color: #000099;
font-weight: bold;
font-size: 13pt;
}
.style2 {color: #FFCC00;
font-weight: bold;
font-size: 14pt;
}
.style3 {color: #CCCCCC;
font-size: 10pt;
}
.style4 {font-size: 10pt}
.style5 {
color: #000099;
font-weight: bold;
font-size: 10pt;
}
.style6 {font-size: 8pt}
.style7 {font-size: 9pt}
-->
</style></head>
<body>
<?php
$db=mysql_connect ("127.0.0.1", "root", "");
mysql_select_db("keywords",$db);
?>
<span class="style1">150 Controlled Keywords</span>
<hr size="0">
<a name="a"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17" class="style2" align="center">A</td>
<td width="17" class="style4" align="center"><a href="#b">B</a></td>
<td width="17" class="style4" align="center"><a href="#c">C</a></td>
<td width="17" class="style4" align="center"><a href="#d">D</a></td>
<td width="17" class="style4" align="center"><a href="#e">E</a></td>
<td width="17" class="style4" align="center"><a href="#f">F</a></td>
<td width="17" class="style4" align="center"><a href="#g">G</a></td>
<td width="17" class="style4" align="center"><a href="#h">H</a></td>
<td width="17" class="style4" align="center"><a href="#i">I</a></td>
<td width="17" class="style4" align="center"><a href="#j">J</a></td>
<td width="17" class="style4" align="center"><a href="#k">K</a></td>
<td width="17" class="style4" align="center"><a href="#l">L</a></td>
<td width="17" class="style4" align="center"><a href="#m">M</a></td>
</tr>
<tr>
<td class="style4" align="center"><a href="#n">N</a></td>
<td class="style4" align="center"><a href="#o">O</a></td>
<td class="style4" align="center"><a href="#p">P</a></td>
<td class="style3" align="center">Q</td>
<td class="style4" align="center"><a href="#r">R</a></td>
<td class="style4" align="center"><a href="#s">S</a></td>
<td class="style4" align="center"><a href="#t">T</a></td>
<td class="style3" align="center">U</td>
<td class="style4" align="center"><a href="#v">V</a></td>
<td class="style4" align="center"><a href="#w">W</a></td>
<td class="style3" align="center">X</td>
<td class="style3" align="center">Y</td>
<td class="style3" align="center">Z</td>
</tr>
</table>
<hr size="0">
<?php
$result=mysql_query("select * from a",$db);
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
while ($rec=mysql_fetch_array($result)) {
$k=$rec['keyword'];
$loc=$rec['location'];
list($k1, $k2) = preg_split('[ .-]', $k);
if ($k1==$k) $key="$k1-$loc";
else $key="$k1-$k2-$loc";
echo "<tr><td>";
echo " <a href='search.php?$key' target='mainFrame'>$rec[keyword]</a>";
echo "</td></tr>";
}
echo "</table>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.