0

Good evening. Please help me.

I built my website on my home pc using Wamp as webserver. On one page I pass arguments to backend.php via URL.

Like this

echo "<a href='backend.php?g=$row[2]'><button >nbsp$row[1]</button></a>";

The code is working fine.

Now I uploaded the site to my godaddy hosting and can’t send the argument in the same manner. I gives me 404. The requested page "/backend.php?g=http://bc.luckyfaucets.com/" could not be found.

The code is exactly the same as on my home server, .htaccess is the same and they both have clean URL enabled. Can someone tell me the cause of this ?

This is the backend.php file.

<?php
define('DRUPAL_ROOT', getcwd());
require_once
DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
variable_set('ref', $_GET['g']);
$g = $_GET['g'];

$con=mysqli_connect($db_host,$db_user,$db_pwd,$database);

// Get infos siteid sitecyle from _sites_
$result = mysqli_query($con, "SELECT `siteid`, `sitecycle` FROM `_sites_` WHERE     `siteurl` = '$g'");

while($row = mysqli_fetch_row($result)) {
$siteid = $row[0];
$sitecycle = $row[1];
// Count time + sitecycle
$next = (time() + ($row[1]*60)+15);
}
// Update _counters_
$result = mysqli_query($con, "SELECT `siteid`, `uid` FROM _counters_ WHERE `uid` ='$user->uid' AND `siteid` ='$siteid'");
if( mysqli_num_rows($result) > 0) {
    mysqli_query($con, "UPDATE _counters_ SET `cycleend` = '$next' WHERE `uid` = '$user->uid' AND `siteid` = '$siteid'");
    }
else
{
    mysqli_query($con, "INSERT INTO _counters_ (uid, siteid, cycleend) VALUES ('$user->uid', '$siteid', '$next')");
 }
 drupal_goto('page');
?>

I would like to know what/why the same code does work with Wamp but not on my hosting. Is this maybe cause by some setting at godaddy?

Thanks for the help

  • Try an absolute URL in your href like: href='example.com/backend.php?g=$row[2]' and report the results. – tvl Oct 29 '14 at 14:58
  • Can you access the backend.php without arguments from your browser? – tvl Oct 29 '14 at 14:58
  • @tvl Thanks for the reply. Yep, I can directly access the php file at example.com/backend.php I also tried theses variations . <a href=’example.com/backend.php?g=$row[2]'> <a href='www.example.com/backend.php?g=$row[2]'> <a href='http://www.example.com/backend.php?g=$row[2]'> Still getting 404 in all cases. – Matthieu Oct 29 '14 at 15:11
  • 1
    Don't use mysqli_query directly if you can avoid it. It seems your code can be subject to SQL injections now. Use Drupal's database API. db_insert, db_update etc will not allow you to make mistakes like that. – Mołot Oct 29 '14 at 15:14
  • Just to get it right, when you type example.com/backend.php in your browser what happens? – Wtower Oct 29 '14 at 15:25
0

Try editing your .htaccess file and uncomment the following line:

RewriteBase /
  • Hi, That was suggested on the drupal site so I did uncomment RewriteBase / But I’m still out of luck, having the same issue. – Matthieu Oct 29 '14 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.