logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Script do not work properly on Windows server/On linux works
Author
bovcan



Joined: 15 Dec 2009
Posts: 19
Location: Slovenia

PostPosted: Wed 06 Jan '10 20:39    Post subject: Script do not work properly on Windows server/On linux works Reply with quote

I have strange problem with website page/php script.
on Windows is not working all corectly.
I get some errors when something must wrote into database(Mysql)

Then I try the same script on VM on system CentOS 5.3(host is Windows 7) and this script is working just fine.
I just do not get it why on Windows is not working as on VMachine?

The addad.php file where errors are on Windows Server:
Code:
<?
if(!defined("ADMIN_PROCESS")) { exit(); }
$ref_title = "Upgrade Settings";

if($admin_loggedin)
{

function filter_data($val)
{
  return htmlentities($val,ENT_QUOTES);
}

if($_POST)
{

$post=array_map("filter_data",$_POST);

mysql_query("INSERT INTO ad_packages (id,clicks,price)
VALUES ('', '{$post['clicks']}', '{$post['price']}');") or die (mysql_error());
$contents .= "<br /><br /><br /><br /><p>Ad Package Added.</p>";
} else {
$contents .= "
<br /><br /><br /><br />
<center>
<form method='post'>
<table width=50% style='border:1px solid black'; cellspacing='0px';'>
   <th align='center' colspan='2' style='border-bottom:1px solid black; background-color: #3799e5;'><font color='white'>Add New Package</font></th>
   <tr class='menu1'>
      <td align='center' style='border-bottom:1px solid black; border-right:1px solid black;'>Clicks:</td>
      <td align='center' style='border-bottom:1px solid black;'><input type='text' name='clicks' value=''></td>
   </tr>
   <tr class='menu2'>
      <td align='center' style='border-bottom:1px solid black; border-right:1px solid black;'>Price:</td>
      <td align='center' style='border-bottom:1px solid black;'>$<input type='text' name='price' value=''></td>
   </tr>
   <tr>
      <td align='center' colspan='2' style='background: #FFFFFF;'><input type='submit' value='Add Ad Package'></td>
   </tr>
</table>
</form></center>";
}
} else {
header("Location: index.php");
}
?>
<style>
tr.menu1:hover
{
background-color:#eeff30;
}
tr.menu2:hover
{
background-color:#eeff30;
}
tr.menu1
{
background-color:#FFFFFF;
}
tr.menu2
{
background-color:#dddddd;
}
</style>


When I click ADD AD Package this error come on a next blank page:
Field 'orderid' doesn't have a default value



In this adcategories.php file nothing happen. If I click on "Add new"(category), popup show up for enter the category name, then another popup report that Advertisment Category was added. But there are no Categories.

Code:
<?
if(!defined("ADMIN_PROCESS")) { exit(); }
$ref_title = "Advertisement Categories";
if($admin_loggedin)
{
$contents .= "<center><br /><br /><br /><br />";
if($_GET['delete'] && !$gen3demo)
{
mysql_query("DELETE FROM ad_catagories WHERE ac_id='{$_GET['delete']}' LIMIT 1;");
mysql_query("UPDATE ads SET aCatagory='1' WHERE aCatagory='{$_GET['delete']}' LIMIT 1;");
$contents .= "<p>Advertisement Category Deleted</p>";
} else {
$q = mysql_query("SELECT * FROM ad_catagories WHERE ac_draft=0");
$contents .= "<center><a href='javascript:;' onclick='addNewCatagory();'>Add New</a><br /><br />
<table width=50% style='border:1px solid black'; cellspacing='0px';'>
<th align='center' colspan='2' style='border-bottom:1px solid black; background-color: #3799e5;'><p><font color='white'>Advertisement Categories</font></p></th>
   <tr>
      <td align='center' style='border-bottom:1px solid black; border-right:1px solid black; background-color: #3799e5;'><p><font color='white'><b>Ad Category Name</b></font></p></td>
      <td align='center' style='border-bottom:1px solid black; background-color: #3799e5;'><p><font color='white'><b>Delete</b></font></p></td>
   </tr>";
$count = 0;
while($r=mysql_fetch_array($q))
{
if($count % 2 == 0 || $count == 0) {
$contents .= "<tr class='menu1'>
            <td align='center' style='border-right:1px solid black;'>{$r['ac_name']}</td>
            <td align='center'><a href='?action=adcatagories&delete={$r['ac_id']}'>Delete</a></td>
           </tr>";
} else {
$contents .= "<tr class='menu2'>
            <td align='center' style='border-right:1px solid black;'>{$r['ac_name']}</td>
            <td align='center'><a href='?action=adcatagories&delete={$r['ac_id']}'>Delete</a></td>
           </tr>";
}
$count++;
}
$contents .= "</table></center>";
}
} else {
header("Location: index.php");
}
?>
<style>
tr.menu1:hover
{
background-color:#eeff30;
}
tr.menu2:hover
{
background-color:#eeff30;
}
tr.menu1
{
background-color:#FFFFFF;
}
tr.menu2
{
background-color:#dddddd;
}
</style>


This a par of js.php file. I guess it is for addcategories.php.
Code:

<?php

if(!defined("ADMIN_PROCESS")) { exit(); }
$stop_ei = true;
header("Content-type: text/javascript");
if($_GET['check'] == "newcat" and $_GET['name'] and $admin_loggedin && !$gen3demo)
{
mysql_query("INSERT INTO ad_catagories VALUES ('', '{$_GET['name']}', '0', '5');");
?>
alert('Advertisement Catagory Added');


I do not get it why this script is working just fine on Linux server, with default configuration.

Regards
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 07 Jan '10 0:15    Post subject: Reply with quote

At the very top of your scripts after <?php add

Code:

ini_set("display_errors",1);
error_reporting(E_ALL);


Also so might enable the php error logging in php.ini

Code:

error_reporting = E_ALL & ~E_NOTICE
log_errors = On
error_log = php_errors.log


Without an error message it is hard to guess.
Back to top
bovcan



Joined: 15 Dec 2009
Posts: 19
Location: Slovenia

PostPosted: Thu 07 Jan '10 23:05    Post subject: Reply with quote

If I add this in php.ini - error_log = php_errors.log apache do not start.

I add this code in addad.php
Code:
ini_set("display_errors",1);
error_reporting(E_ALL);

And I get this errors:


Notice: Undefined variable: contents in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\addad.php on line 42

Notice: Undefined variable: stop_ei in L:\SERVER\Apache2.2\htdocs\WEB\admin\index.php on line 47

Notice: Undefined variable: stop_ei in L:\SERVER\Apache2.2\htdocs\WEB\admin\index.php on line 49

Notice: Undefined variable: HTTP_REFERRER in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\footer.php on line 19

Notice: Undefined variable: ir in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\footer.php on line 19

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\footer.php on line 19


ERROR LINES:

Code:

addad.php on line 42
[b]</form></center>";[/b]
index.php on line 47
[b]if(!$stop_ei) { include_once("pre/header.php"); }[/b]
index.php on line 49
[b]if(!$stop_ei) { include_once("pre/footer.php"); }[/b]
footer.php on line 19
[b]mail($set['contact_email'],"Hack Alert","There's been a SQL Injection hacking attempt. $HTTP_REFERRER $REMOTE_ADDR","FROM:".$ir['email']);[/b]


-------------------------------------------------------------------------------------

I add this code in adcategories.php
Code:
ini_set("display_errors",1);
error_reporting(E_ALL);

And I get this errors:


Notice: Undefined variable: contents in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\adcatagories.php on line 8

Notice: Undefined index: delete in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\adcatagories.php on line 9

Notice: Undefined variable: stop_ei in L:\SERVER\Apache2.2\htdocs\WEB\admin\index.php on line 47

Notice: Undefined variable: stop_ei in L:\SERVER\Apache2.2\htdocs\WEB\admin\index.php on line 49

THIS ARE THE SAME
Notice: Undefined variable: HTTP_REFERRER in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\footer.php on line 19

Notice: Undefined variable: ir in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\footer.php on line 19

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in L:\SERVER\Apache2.2\htdocs\WEB\admin\pre\footer.php on line 19

ERROR LINES:

Code:

adcatagories.php on line 8
[b]$contents .= "<center><br /><br /><br /><br />";[/b]
adcatagories.php on line 9
[b]if($_GET['delete'] && !$gen3demo)[/b]
\index.php on line 47
[b]if(!$stop_ei) { include_once("pre/header.php"); }[/b]

-----------------------------------------------------------------------------------
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 07 Jan '10 23:49    Post subject: Reply with quote

Your script breaks / stops because your script can't send a mail. No connection to the mail server.
Since you said it works on linux, but not on windows. On Linux php can use sendmail to send mails, but on windows you have to run a mail server.

Code:

 Failed to connect to mailserver at "localhost" port 25
Back to top
bovcan



Joined: 15 Dec 2009
Posts: 19
Location: Slovenia

PostPosted: Fri 08 Jan '10 10:07    Post subject: Reply with quote

Ok, will try to setup mail server on windows.
Do you suggest witch mail server is OK?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 08 Jan '10 14:40    Post subject: Reply with quote

I prefer Mercury Mail Transport System. Other people like other mail servers Wink
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 08 Jan '10 14:47    Post subject: Reply with quote

You should try to change your scripts that they don't stop executing if there is no mail, but display an error message like

Code:

<?php
if( ! mail($to,$subject,$message) ){
   echo 'Whoops failed to send mail';
}
Back to top


Reply to topic   Topic: Script do not work properly on Windows server/On linux works View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner