?
Solved

PHP error  Notice Undefined offset

Posted on 2006-04-21
3
Medium Priority
?
952 Views
Last Modified: 2008-01-09
Hi,

I have this code and it is working on a server from profider A, when I copy the files to an other profider it gives this error:
"Notice: Undefined offset: 1 in c:\hosting\webhost4life\member\netvanhagen\leasewebsite\sk_php\public_html\subcat.php on line 30"

Line 30 is:
$row[3] = $split[1];

This is a part of the script:
<?
$cols = 3;
$rows = $num / $cols;
for ($i=0;$i<$rows;$i++) {
      echo "</tr>";
      for ($ie=0;$ie<$cols;$ie++) {
            echo "<td class=\"standard\">";
            if ($row = mysql_fetch_row($query)) {
                  if ($row[3] == "none") {
                        $img = "<img src=\"images/na.jpg\" border=\"0\">";
                  } else {
                        $split = explode("../", $row[3]);
                        $row[3] = $split[1];
                        $img = "<img src=\"$row[3]\" border=\"0\">";
                  }
                  echo "</tr><tr>";
                  echo '<td border="0" cellpadding="0" cellspacing="0" style="width:220px;height:25px;background-color:#FE9900;text-align:center; vertical-align:middle;" valign="middle"><a  href="articles.php?sid='.htmlspecialchars($row[0]).'" class="product">'.htmlspecialchars($row[2]).'</a><br>'."\n";
                  echo "<br>";
            } else {
                  echo "&nbsp;";
            }
            echo "</td>\n";
      }
      echo "<tr>";      
}
?>



What is wronge???

Thanks,
HP
0
Comment
Question by:WvR
3 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 16505119
Isn't it easier to use:

Replace
$split = explode("../", $row[3]);
                    $row[3] = $split[1];
With

$row[3] = preg_replace('#^../#','',$row[3]);

-r-
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16505147
   $row[3] = $split[sizeof($split)];
0
 
LVL 1

Author Comment

by:WvR
ID: 16505437
Thanks, this is it!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 14 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question