<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Getting last record php warning</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Getting-last-record-php-warning-82277</link>
        <description></description>
        <pubDate>Mon, 13 Apr 2026 07:51:57 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Getting-last-record-php-warning-82277" rel="self" type="application/rss+xml" />

                <item>
          <title>Getting last record php warning</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2244828#post2244828</link>
          <description><![CDATA[<p>Hi,</p>
<p>Thanks for the help.</p>
<p>I tried following Jerry's advice but couldn't figure out how to apply it to record view, not images, and have been working around, but suddenly, the error stopped when I typed in the first code again.</p>
<p>I guess I had something wrong somewhere.</p>
<p>Sorry for the fuss and thank you!</p>
<p>Best,</p>
<p>Hiroko</p>]]></description>
          <pubDate>Mon, 22 Jun 2020 19:48:15 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2244828#post2244828</guid>
        </item>
                <item>
          <title>Getting last record php warning</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2244822#post2244822</link>
          <description><![CDATA[<p>Hi Hiroko,</p>
<p>Generally, your code should work; the error message indicates that a "bad" whitespace character has been copied into your code. Essentially an invisible character that <em>looks</em> like a space or tab but isn't recognized as such by the PHP engine. One way to find the offending character is if your code editor has an option along the lines of "show hidden/invisible/non-printable characters" - with this turned it should stand out from the rest of the whitespace in your code, allowing you to delete/replace it. If you're unable to do this, I would recommend commenting/removing portions of your code until you find the line(s) that trigger the error, then re-typing that code from scratch.</p>
<p>Also, in addition to Jerry's method, another potentially simpler way to handle the "," could be to use a counter variable, something like this:</p>
<pre class="language-php"><code>&lt;?php $count = 0; ?&gt;
&lt;?php foreach ($itemRecords as $record): ?&gt;
  &lt;?php if ($count++ &gt; 0): ?&gt;,&lt;?php endif; ?&gt;
  some codes
&lt;?php endforeach ?&gt;</code></pre>
<p>Let me know if you have any more questions!</p>
<p>Thanks,</p>]]></description>
          <pubDate>Mon, 22 Jun 2020 14:25:39 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2244822#post2244822</guid>
        </item>
                <item>
          <title>Getting last record php warning</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2244813#post2244813</link>
          <description><![CDATA[<p>Hi Hiroko,</p>
<p>Sorry, I don't know about the error you're getting but I've been getting rid of the last comma by using rtrim</p>
<p>Here's an example for some images in a list</p>
<p><span class="Medium-Text">&lt;?php  $output <span style="color:#000;">= </span>''<span style="color:#000;">; </span>?&gt;<br /><br />&lt;?php <span style="color:#000;">foreach (</span>$home_page_slide_showRecord<span style="color:#000;">[</span>'images'<span style="color:#000;">] as </span>$upload<span style="color:#000;">)  { <br />      </span>$output <span style="color:#000;">.= </span>'{ src: ' <span style="color:#000;">. </span>'"' <span style="color:#000;">.</span>$upload<span style="color:#000;">[</span>'thumbUrlPath'<span style="color:#000;">]. </span>'"' <span style="color:#000;">. </span>'}'<span style="color:#000;">. </span>',' <span style="color:#000;">; <br />    } </span>?&gt;<br /><br />   &lt;?php  $output <span style="color:#000;">= </span>rtrim<span style="color:#000;">(</span>$output<span style="color:#000;">,</span>','<span style="color:#000;">); </span>// remove trailing comma ?&gt;<br /><br />   &lt;?php <span style="color:#000;">print </span>$output<span style="color:#000;">; </span>?&gt;</span></p>
<p><span class="Medium-Text">Hope that helps,</span></p>
<p><span class="Medium-Text">Jerry Kornbluth</span></p>
]]></description>
          <pubDate>Sat, 20 Jun 2020 08:51:56 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2244813#post2244813</guid>
        </item>
                <item>
          <title>Getting last record php warning</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2244812#post2244812</link>
          <description><![CDATA[<p>Hi,</p>
<p>I am trying to use end($myRecords) to get the 'num' of the last record listed in a viewer.</p>
<p>The result is fine, but I have a PHP warning that says </p>
<p>"<span>Warning: Use of undefined constant     - assumed '   ' (this will throw an Error in a future version of PHP)"</span></p>
<p>I just want to get rid of the comma on the last item.</p>
<pre class="language-markup"><code>&lt;?php // get last record num
	$lastRecord = end($itemRecords);
	$lastRecordNum = $lastRecord['num'];
?&gt;
&lt;?php foreach ($itemRecords as $record): ?&gt;
some codes
&lt;?php if ($lastRecordNum != $record['num']): ?&gt;,&lt;?php endif ?&gt;
&lt;?php endforeach ?&gt;</code></pre>
<p>Can someone tell me why I am getting this warning and how I could fix it?</p>
<p>Thank you,</p>
<p>Hiroko</p>]]></description>
          <pubDate>Sat, 20 Jun 2020 08:16:23 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2244812#post2244812</guid>
        </item>
              </channel>
    </rss>
  