testing for source to use

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

In this bit of code, the procedure is fairly simple.
1) get the value from the database.
2) check the value to find out what the first character is.
3) if the first character is "/" then the source is my site.
4) if not, the source is youtube.

I chose the / because I've never seen it used in the values on youtube.
and it makes finishing off the url easier.

the problem is, no matter what link I select, the url is always MY SITE!

What other ways can I do this?

Oh, and Beau dear? Shut the fuck up with seeing a big blank page because
that makes you a liar.  


$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];


if ($v1="/"){$yt="http://mroldies.net ".$vid[0];}
echo "<br />".$yt;

Re: testing for source to use

richard the sto0pid wrote:

Quoted text here. Click to load it

That's not the same page, sto0pid.

Your previous iteration - that which I was talking about - was completely  
blank when JavaScript is blocked or not enabled.

This:  http://www.mroldies.net/test3.html which at this moment is still  
active, and blank.

BTW, you should hire someone who has at least a scrap of artistic  
abilities. You certainly don't.

   -This space for rent, but the price is high

Re: testing for source to use

On Thu, 23 May 2013 23:23:51 -0400, richard wrote:

Quoted text here. Click to load it

Should be:
if ($v1=="/"){$yt="http://mroldies.net ".$vid[0];} echo "<br />".$yt;

I think you've been advised of a similar error recently.


Re: testing for source to use


Quoted text here. Click to load it

Quoted text here. Click to load it

Same problem you had on your last question: the above is an assignment
statement, not a  
comparison. The equality comparison operator in php is ==, not =.

Re: testing for source to use

On 5/23/2013 8:23 PM, richard wrote:

Quoted text here. Click to load it

Richard.....*lost for words*


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.


Re: testing for source to use

On Fri, 24 May 2013 05:38:44 -0700, Scott Johnson wrote:

Quoted text here. Click to load it

FYI, I found that I could use the substr() function to solve my problem
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.
The output is "1" correct?
It is "2".
To output the "1", the correct code is substr("123",0,1).
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.

Re: testing for source to use

On 5/24/2013 12:22 PM, richard wrote:
Quoted text here. Click to load it

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.

Site Timeline