473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Script error under PHP 4.3.3

Could anyone identify why the following script is giving me various errors
under php 4.3.3. It worked fine on previous versions.

function cut_string($string,$wordnum,$trail)
{
$string_arr=explode(" ",$string);
for($i=0;$i<$wordnum;$i++)
{
$re_string.= " ".$string_arr[$i];
}
$str= $re_string.$trail;
print $str;
}

Thanks in advance
Jul 17 '05 #1
4 1670
Andrew Banks wrote:
Could anyone identify why the following script is giving me various errors
under php 4.3.3. It worked fine on previous versions.


maybe telling wich errors comes out would help...

--
WM
Jul 17 '05 #2
On Mon, 06 Oct 2003 09:05:13 GMT, "Andrew Banks"
<ba****@nospamblueyonder.co.uk> wrote:
Could anyone identify why the following script is giving me various errors
under php 4.3.3. It worked fine on previous versions.
Post the 'various errors'.
function cut_string($string,$wordnum,$trail)
{
$string_arr=explode(" ",$string);
for($i=0;$i<$wordnum;$i++)
{
$re_string.= " ".$string_arr[$i];
}
$str= $re_string.$trail;
print $str;
}


Compiles fine here under 4.3.3. If it's giving errors at runtime, post
examples of data that cause them, and the errors themselves.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
Andrew Banks wrote:
Could anyone identify why the following script is giving me various errors
under php 4.3.3. It worked fine on previous versions.

function cut_string($string,$wordnum,$trail)
{
$string_arr=explode(" ",$string);
### check wordnum against actual number of words in string_arr
if ($wordnum > count($string_arr)) $wordnum = count($string_arr);

### and please, please, please initialize re_string
$re_string = '';
for($i=0;$i<$wordnum;$i++)
{
$re_string.= " ".$string_arr[$i];
}
$str= $re_string.$trail;
print $str;
}

Thanks in advance

If you'd tell us what the errors are it might be easier to tell you why
they show up.

--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #4

"Andrew Banks" <ba****@nospamblueyonder.co.uk> wrote in message
news:df**********************@news-text.cableinet.net...
Could anyone identify why the following script is giving me various errors
under php 4.3.3. It worked fine on previous versions.

function cut_string($string,$wordnum,$trail)
{
$string_arr=explode(" ",$string);
for($i=0;$i<$wordnum;$i++)
{
$re_string.= " ".$string_arr[$i];
}
$str= $re_string.$trail;
print $str;
}


I imagine that $wordnum > count ($string_arr) for the set of parameters
you're passing to this function. You need to modify your routine to count up
to $wordnum only if count ($string_arr) >= $wordnum.

Paulus
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Will Seay | last post by:
At the end of this message I've pasted a script we're trying to modify slightly. I don't believe it is VBscript or javascript but these are the closest groups I could find with my limited...
6
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of...
12
by: tshad | last post by:
I am not sure why I am getting this error: I have the following code I want to run from another include file that holds all my functions. functions.inc...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
5
by: Bjorn Sagbakken | last post by:
Hello I have just migrated from VS 2003 to VS 2005, and .NET framework 1.1 to 2.0 I am at the end of debugging and fixing stuff. Now there is one error I just cannot find a solution to: On...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
7
by: jeddiki | last post by:
Hi, As I am in Turkey at present, I can not see vidoes on youtube. So I have tried a few proxies but keep finding them slow or not working. So I have installed myphpProxy on my server under...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.