Jump to content

[SOLVED] Please Check This Code for Me. Will It Work?


Fluoresce

Recommended Posts

Will the following code work? I can't test it for various reasons. It must, must work first time round, so please be thorough with your evaluations.

 

Basically, I want to count how many clicks my links get. I've put my links in a database. When someone clicks a link on my site (which look like this: goto.php?id=1), they are sent to goto.php, which:

 

  • gets the ID
  • connects to the database
  • updates the Count column of the link table
  • selects the real link (note: this has a variable appended to it: http://www.whatever.com?=$var)
  • redirects the visitor to the location

 

What I am particularly worried about are the variables appended to the links in the database. Will they be echoed properly?

 

<?php

$id = intval($_GET['id']);

$conn = mysql_connect('localhost','root') or trigger_error("SQL", E_USER_ERROR); 
mysql_select_db('ctyi', $conn) or trigger_error("SQL", E_USER_ERROR);

mysql_query("UPDATE table SET count = count+1 WHERE id=$id"); 

$href = "SELECT url FROM table WHERE id=$id";

$qry = mysql_query($href);

list($href)=mysql_fetch_row($qry); // list() because an array is returned

eval("\$href = \"$href\";");

header("Location:$href");

mysql_close($conn);

?> 

Did you understand what I asked?

 

Yes. You expected people here to create a small database, populate it, write a script, etc. and test it 'thoroughly' all for free because you can't test it for reasons you don't disclose.  And, in effect, you expected the testers to guarantee it would work.  And in return, you offered what? Nothing.  That's not the nature of help this forum provides.  Our time is at least as important as yours.

why cant this be tested?

 

The only way will be to enter my site from an external site, click on a link which directs to an online store, and buy something from that store to see if the value of the appended variable appears in my affiliate network account.

 

All I want, therefore, is someone to simply look over my code for any obvious errors. Can you see any?

Did you understand what I asked?

 

Yes. You expected people here to create a small database, populate it, write a script, etc. and test it 'thoroughly' all for free because you can't test it for reasons you don't disclose.  And, in effect, you expected the testers to guarantee it would work.  And in return, you offered what? Nothing.  That's not the nature of help this forum provides.  Our time is at least as important as yours.

 

What?!  ???

 

Dude, I didn't ask you for anything. All I wanted was for someone to look over my code - which is only a few lines long - and to tell me if there were any obvious errors. You've practically accused me of murder!  ???

Did you understand what I asked?

 

Yes. You expected people here to create a small database, populate it, write a script, etc. and test it 'thoroughly' all for free because you can't test it for reasons you don't disclose.  And, in effect, you expected the testers to guarantee it would work.  And in return, you offered what? Nothing.  That's not the nature of help this forum provides.  Our time is at least as important as yours.

 

What?!  ???

 

Dude, I didn't ask you for anything. All I wanted was for someone to look over my code - which is only a few lines long - and to tell me if there were any obvious errors. You've practically accused me of murder!  ???

 

I may be wrong, but he no one can gaurente if it will work because we dont have the database etc...Also why cant you test it your self :o that intrests me.

I may be wrong, but he no one can gaurente if it will work because we dont have the database etc...Also why cant you test it your self :o that intrests me.

 

As I said above, the only way for me to test it would be to enter my site from an external site, click on a link which directs to an online store, and buy something from that store to see if the value of the appended variable appears in my affiliate network account.

 

I thought, therefore, that I should just simply ask in a forum if any professionals can see any obvious errors. Apparently, it wasn't the best idea: people are accusing me of world hunger, famine and just about every other problem!  ???

Local host is a offline thing tho? download xampp and ur good to go, you dont need to buy xampp

 

I'm already using XAMPP. The code seems to work perfectly, but I don't know if the variable appended to the links is being passed on. The only way to find out would be to buy something through one of my own links, which, as I said, isn't allowed. This leaves me with a problem . . . I can either get someone to buy something through one of my links, or ask in a forum for clarification.

 

Can you see any obvious errors in the code?

Your theory must be wrong here, i am pretty postive you can test this stuff with out having to buy somthing. Because, well, it will be flat out idiotic if no one in the world designed somthing to suit this. And no i cant see any error, but im new so, might not wanna take my word for it.

Fluoresce, I think what people are trying to tell you is that there is always a way to test these things. Put another way, do you think all these e-commerce sites go live without testing first? In hoping that there is no serious issues? This is not proper development practices.

 

Despite what is 'not allowed' with regards to your affiliates, I'm sure your affiliates would certainly not appreciate going live without testing and having everything come crashing down. While I don't develop e-commerce sites, there must be ways to test locally. I would look into professional e-commerce practices with regards to testing. Dig around a little.

 

One way or another, I'm going to fathom a guess that e-commerce sites don't blindly launch (because they were not allowed to test locally) and hope for the best. This is a fast receipy for disaster. No one in their right minds should ever consider launching without thorough local testing first.

 

Cheers,

 

NRG

 

P.S No one is accusing you of murder, famine nor world hunger (let's not be dramatic about this in a childish manner). Just due your due diligence as you have a responsibility to not only your affiliates, but most importantly, the users who *risk* purchasing something from an online store you built. If you are not experienced enough, then perhaps this alone is a red-flag sign that this is better suited for someone else with greater experience / expertise. I mean no offense to you by any of this.. it's just common sense. Be very careful when dealing with e-commercing.. very serious stuff.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.