FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » testing for source to use
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: testing for source to use [message #181667 is a reply to message #181662] Fri, 24 May 2013 22:12 Go to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma:
Senior Member
On 5/24/2013 12:22 PM, richard wrote:
> On Fri, 24 May 2013 05:38:44 -0700, Scott Johnson wrote:
>
>> On 5/23/2013 8:23 PM, richard wrote:
>>
>>>
>>> $result = mysql_query("SELECT avid FROM A$year WHERE id = $number");
>>> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
>>> $vid = mysql_fetch_row($result);
>>>
>>> echo $vid[0];
>>> $v=$vid[0];
>>> $v1=substr($v,0,1);
>>>
>>>
>>> $yt="http://www.youtube.com/watch?v=".$vid[0];
>>>
>>> if ($v1="/"){$yt="http://mroldies.net".$vid[0];}
>>> echo "<br />".$yt;
>>>
>>
>> Richard.....*lost for words*
>>
>> *refound*
>>
>> Brother you really should start keeping notes of these simple errors.
>> You keep revisiting the errors that people do when they first start
>> using PHP.
>>
>> Many in the NG have taken their own time to point these out and give you
>> good advice, and to not learn or write the solutions down is being very
>> disrespectful to those peoples times, which is why you probably get many
>> disparaging comments.
>>
>> I have a very bad memory myself but I keep a notebook and revisit it
>> whenever I run into an error to ensure I (or someone else) have not
>> already solved it previously.
>>
>> Just a suggestion.
>>
>> Scotty
>
> FYI, I found that I could use the substr() function to solve my problem
> with.
> With everything that I had read, there was one very important thing every
> one of these writers left out!
> That being, the natural mind says the first character is "1" and therefore
> the number 1 should be used if you want to start at the begining.
> e.g.
> substr("123",1,1)
> The output is "1" correct?
> Wrong!
> It is "2".
> To output the "1", the correct code is substr("123",0,1).
> Why?
> I suspect that this is due to the fact the substring is treated as an array
> and the array always begins with [0] by default.
>


Yes that is the expected return/functionality of substr(), especially if
you read the 'manual' on the function. It specifies that 0 is the base.

Always remember (or write it down). php.net is your friend.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: use a value form a manu list in a form on the same page
Next Topic: TEST only
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 11:52:33 GMT 2024

Total time taken to generate the page: 0.04124 seconds