You are here: Re: undefined index « PHP Programming Language « IT news, forums, messages
Re: undefined index

Posted by Chris on 07/25/06 18:05

Hi Tom,

I don't understand how to initialize it. I have tried assigning it a null
value, and other values. I have tried to use a different parameter for my
if statement, but it also comes back as undefined index. I have added the
proj.projID to the query, I have moved stuff around. I have added to,
removed from and edited the query, changed things around, etc. So, what am
I missing here? None of my other queries and code have this issue and they
are done pretty much the same, other than having a 'keyword'. Code Repasted
for another review (can someone point out the area that I'm not getting
right?):

<?php
include("includes/header.php");
$keyword = $_POST['keyword'];

mysql_select_db($database_website, $website);
$query_search = "SELECT Distinct docURL, docTitle, docDesc, docs.projID,
groupCode, projCode, catName FROM docs
JOIN subcat on subcat.subcatID=docs.subcatID
JOIN cat on cat.catID = subcat.catID
JOIN groups on groups.groupID=proj.groupID
JOIN proj on proj.projID=docs.projID
WHERE proj.projID=docs.projID AND docURL LIKE '%$keyword%' OR docTitle LIKE
'%$keyword%' OR docDesc LIKE '%$keyword%'";
$search = mysql_query($query_search, $website) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);
$totalRows_search = mysql_num_rows($search);
$proj = $row_search['projCode'];

?>
<?php if ($totalRows_search < 1)
{
echo "No internal documents matched your request.";
}

else {?>

<p><table width=95%>
<tr><td colspan="3"><font size="+1">Internal Documents:</font></td>
</tr>
<tr>
<td><strong> Link </strong></td>
<td> <strong>Description</strong></td>
<td> <strong>Project </strong></td>
</tr>
<?php
do { ?>
<tr>
<td>
<a href="<?php if ($row_search['proj.projID'] == 1) {
echo $row_search['catName']."/".$row_search['docURL'];
}
else {
echo
$row_search['groupCode']."/".$row_search['projCode']."/".$row_search['catName']."/".$row_search['docURL'];
?>"><?php echo $row_search['docTitle'];
} ?></a></td>
<td><?php echo $row_search['docDesc']; ?></td><td><?php echo
$row_search['projCode']; ?></td>
</tr>
<?php } while ($row_search = mysql_fetch_assoc($search)); ?>

</table>
<?php }?>
</p>
<?php
mysql_select_db($database_website, $website);
$query_search = "SELECT Distinct toolURL, toolName, toolDesc, tools.projID,
projCode FROM tools
JOIN proj on proj.projID=tools.projID WHERE toolURL LIKE '%$keyword%' OR
toolName LIKE '%$keyword%' OR toolDesc LIKE '%$keyword%'";
$search = mysql_query($query_search, $website) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);
$totalRows_search = mysql_num_rows($search);

?>
<?php if ($totalRows_search < 1)
{
echo "No tools matched your request.";
}

else {?>

<p><table width=95%>
<tr><td colspan="3"><font size="+1">Tools:</font></td>
</tr>
<tr>
<td><strong> Link </strong></td>
<td> <strong>Description</strong></td>
<td> <strong>Project </strong></td>
</tr>
<?php do { ?>
<tr>
<td>
<a href="<?php echo $row_search['toolURL']; ?>"><?php echo
$row_search['toolName']; ?></a></td><td><?php echo $row_search['toolDesc'];
?></td><td><?php echo $row_search['projCode']; ?></td>
</tr>
<?php } while ($row_search = mysql_fetch_assoc($search)); ?>

</table>
<?php }?>
</p>

<?php
mysql_select_db($database_website, $website);
$query_search = "SELECT Distinct pageURL, pageName, pageDesc, links.projID,
projCode FROM links
JOIN proj on proj.projID=links.projID WHERE pageURL LIKE '%$keyword%' OR
pageName LIKE '%$keyword%' OR pageDesc LIKE '%$keyword%'";
$search = mysql_query($query_search, $website) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);
$totalRows_search = mysql_num_rows($search);

?>
<?php if ($totalRows_search < 1)
{
echo "No external documents matched your request.";
}

else {?>

<p><table width=95%>
<tr><td colspan="3"><font size="+1">External Documents:</font></td>
</tr>
<tr>
<td><strong> Link </strong></td>
<td> <strong>Description</strong></td>
<td> <strong>Project </strong></td>
</tr>
<?php do { ?>
<tr>
<td>
<a href="<?php echo $row_search['pageURL']; ?>"><?php echo
$row_search['pageName']; ?></a></td><td><?php echo $row_search['pageDesc'];
?></td><td><?php echo $row_search['projCode']; ?></td>
</tr>
<?php } while ($row_search = mysql_fetch_assoc($search)); ?>

</table>
<?php }?>
</p>
<?php
mysql_free_result($search);
include("includes/footer.php"); ?>


<tomwerner@gmail.com> wrote in message
news:1153250073.720919.208950@s13g2000cwa.googlegroups.com...
> Hi,
>
> Technically undefined index errors should not affect your script,
> however, if you want to get rid of these warnings then make sure you
> initialise that index, the best way being assigning it a null value.
>
> Tom
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация