Jump to content

Problem With Script When Change Server


ulisses

Recommended Posts

Hi all!I have a trouble that I don't know how to solve.I've made a php program on my computer, that works perfectly. Now that's done I've passed the scripts to another server, so that anyone within the network could use it.The problem is: in this another one server, the program isn't behaving the way it should!And is not a connection problem, because i've checked everything and the connection is ok!The scripts are the same, so why is not running the way it was supposed to?Anyone has any idea of what is happening, or any of u has already got into this trouble?I'd appreciate any help!Thanks in advance!

Link to comment
Share on other sites

Perhaps the server is running a different version of PHP or isn't at all. To find out, either ask the server admin or create a phpinfo.php file and upload it. Sometimes you need to change the extension to use different versions of PHP - I need to use .php5 to use PHP5, .php4 to use...well, you can guess.

Link to comment
Share on other sites

Some installations of PHP do not allow short tags.Short tags look like this <? doSomething() ?>Normal tags look like this <?php doSomething() ?>So if you are using short tags, you might change them to normal tags. It may or may not make a difference.

Link to comment
Share on other sites

Is SAFE MODE "on" or "off" at the remote Server?Are you using the $_REQUEST array?Can we see your code and also, what version of PHP is the Localhost??? and the Remote Server???

Link to comment
Share on other sites

Does it use databases? Are the databases set up the same?Are you using some extensions that aren't supported on the remote server?

Link to comment
Share on other sites

Does it use databases? Are the databases set up the same?
Yes, it uses databases, and there's a difference on collations. In mine it is latin1_general_ci and in the other server it is latin1_swedish_ci.But does this have something to do with the code?
Are you using the $_REQUEST array?
No, in fact I'm not using the $_REQUEST. But if I was, what is the problem with it?Well, I'll show the code for one page and maybe u could understand it better, or maybe u can see something that my inexperience doesn't see.
<?php session_start(); ?><html><body><div class="leftmenu"><?php require("menu.php"); ?></div></body></html> <?php$con = mysql_connect("servername","username","password");						  if (!$con)   {																												     die('Could not connect: ' . mysql_error());								   }																												   																													  mysql_select_db("faf", $con);$var=$_SESSION['insert'];$int_options = array("options"=>array  (  "min_range"=>9100000,  "max_range"=>9299999  ));																					   																													   mysql_query("SELECT msisdn FROM faf");   $lastup=mysql_query("SELECT date FROM faf WHERE msisdn='$_SESSION[insert]' AND class_id=1");  $alup=mysql_fetch_array($lastup);  $date=$alup['date'];    $max=mysql_query("SELECT MAX(date) AS maxdate FROM log_faf WHERE number='$_SESSION[insert]' AND type='club_t+'");   $maxi=mysql_fetch_array($max);  $big=$maxi['maxdate'];     $diffc=mysql_query("SELECT DATEDIFF(CURDATE(),'$maxi[maxdate]') AS datediff");  $arrayc=mysql_fetch_array($diffc);  $marrayc=$arrayc['datediff'];   $days=30-$arrayc['datediff'];																																																																													    $club=array($_POST['numberc1'],$_POST['numberc2'],$_POST['numberc3'],$_POST['numberc4'],$_POST['numberc5']);	  $ccount=mysql_query("SELECT COUNT(msisdn) AS contar FROM faf WHERE msisdn='$_SESSION[insert]' AND class_id=1");  $mais=mysql_fetch_array($ccount);     $cont_add=mysql_query("SELECT COUNT(number) AS cont_add FROM log_faf WHERE number='$_SESSION[insert]' AND action='add' AND type='club_t+'");     $cont_log=mysql_fetch_array($cont_add);   	 if($cont_log['cont_add'] >= 5 && $arrayc['datediff'] < 30)	 {	 echo "You have added for more than 5 times. For now, you can not add more on Club T+. Need more " . $days . " days!</br>";	 }	 else 		  for($i=0;$i < 5; $i++ )		  {				    $cconta=mysql_query("SELECT COUNT(msisdn) AS sum FROM faf WHERE msisdn='$_SESSION[insert]' AND faf_number='$club[$i]'");  $more=mysql_fetch_array($cconta); 				  		  if($mais['contar'] < 5 && $more['sum'] < 1 && $club[$i] != $_SESSION['insert']) 	 			  {				  				 if(filter_var($var, FILTER_VALIDATE_INT, $int_options) && filter_var($club[$i], FILTER_VALIDATE_INT, $int_options))				 {																   		  mysql_query("INSERT INTO faf (msisdn, faf_number, type, class_id) VALUES ('$_SESSION[insert]',$club[$i],'club_t+',1)");		  $sql="INSERT INTO faftm (mymsisdn, myfaf_number, date, faftype, class_id) VALUES('$_SESSION[insert]',$club[$i],CURDATE(),'club_t+',1)";		  if (!mysql_query($sql,$con))			{			echo('Error: ' . mysql_error());			}	   		  $sql="INSERT INTO log_faf (number, action, faf, type) VALUES('$_SESSION[insert]','add',$club[$i],'club_t+')";		  if (!mysql_query($sql,$con))			{			echo('Error: ' . mysql_error());			}		  $mais['contar']++;				  		mysql_query("UPDATE faf SET date=CURDATE() WHERE msisdn='$_SESSION[insert]' AND class_id=1");		   echo "The number " . $club[$i] . " has been added successfully on Club T+</br>";  				 }				elseif(!filter_var($var, FILTER_VALIDATE_INT, $int_options))				  echo $_SESSION['insert'] . " is not a valid MSISDN</br>";				  elseif(!filter_var($club[$i], FILTER_VALIDATE_INT, $int_options) && strlen("$club[$i]") > 0)				  echo $club[$i] . " is not a valid number</br>";				}				else				if($club[$i] == $_SESSION['insert'])				{				echo "You can't add your own number on Club T+!</br>";				}				else				if($more['sum'] >= 1)				{				echo "The number" . " " . $club[$i] . " " . "is already on the" . " " . $_SESSION['insert'] . "'s list</br>";				}				else				if($mais['contar'] >= 5 && strlen("$club[$i]") == 7)				{				echo "The number" . " " . $club[$i] . " " . "couldn't be inserted because there's already" . " " . $mais['contar'] . " " . "numbers in Club t+, last updated at" . " " . $alup['date'] . "<br />";						}				if(strlen("$club[$i]") > 0 && strlen("$club[$i]") != 7)				{				echo "Check if the number" . " " . $club[$i] . " " . "is correctly typed</br>";				}			 }								 if(strlen("$_SESSION[insert]") != 7)			 {			   echo "The MSISDN field is not correctly filled!</br>";			 }				 mysql_close($con);?>

Link to comment
Share on other sites

What is the code doing that is not correct? Are you seeing any errors?
No, ther is no error dysplayed. The problem comes from this part:
elseif(!filter_var($club[$i], FILTER_VALIDATE_INT, $int_options) && strlen("$club[$i]") > 0)				  echo $club[$i] . " is not a valid number</br>";

It is echoing "is not a valid number"!Thanks!

Link to comment
Share on other sites

Then it sounds like $club[$i] is not a valid number. Check the value, it should be printing the value in the error message. If the only thing it prints is "is not a valid number" then the value is blank, and a blank value is not a valid number.

Link to comment
Share on other sites

Then it sounds like $club[$i] is not a valid number. Check the value, it should be printing the value in the error message. If the only thing it prints is "is not a valid number" then the value is blank, and a blank value is not a valid number.
No, the value isn't blank! It prints the number inserted followed by "is not a valid number". Sorry if I haven't been clearer before.And as I said, it's working fine on my computer, the problem is when I change from servers.
Link to comment
Share on other sites

Add this line below where it prints the message:var_dump($club[$i]);Copy and paste what it prints for that.But here's the thing: if this is your code:elseif(!filter_var($club[$i], FILTER_VALIDATE_INT, $int_options) && strlen("$club[$i]") > 0)echo $club[$i] . " is not a valid number</br>";It will only print that error message if the call to filter_var fails, and the variable has at least one character in it. If both of those are true it will print the message, so if it's printing the message then both of those must be true. Keep in mind you're also giving it a minimum and maximum value for the number.Also, the filter_var function requires at least PHP 5.2.

Link to comment
Share on other sites

Add this line below where it prints the message:var_dump($club[$i]);Copy and paste what it prints for that.
Yap, I've seen something that I never saw before. It is printing "NULL NULL NULL NULL NULL".
Link to comment
Share on other sites

I've finnally solved it!Thanks to all of u that had replied to my post, especially justsomeguy, thanks to u i've solved it.The var_dump() idea was such a brilliant one, and it have opened my eyes to see where the mistake was.It was considering the inserted numbers as string and not as an integer, that was the problem.Now I've removed the filter_validate_int and it is inserting normally as a string.Thanks a lot again!!

Link to comment
Share on other sites

Fortunatelly u replied me again. I was so excited that I couldn't see that removing the filter I could have unwanted values inserted.With intval() or is_numeric it is working better. Now it has only one problem:It is not considering the $nat_options on the filter.Thanks

Link to comment
Share on other sites

I don't see a $nat_options, did you mean $int_options?
sorry for this, I've changed the name while I was updating the code, to help understand better the code. But it is the same as $int_options!
Link to comment
Share on other sites

I've realized that the problem is with the integer size. It doesn't accept number with more than 9 digits.I've seen it because now my range is between 2389100000 and 2389999999. It's accepting for example 238910000, but 2389100000 not.I still working on it, and I was searching and found something about 32bit size. Anything about this?

Link to comment
Share on other sites

The maximum value for a signed 32-bit integer is 2147483648. Check here for one way to work around that:http://www.biorust.com/tutorials/detail/256/en/They're using MySQL to do the calculation because MySQL uses 64-bit integers, you could also use MySQL to check the bounds. If you did that, it would be best to leave the number as a string instead of converting it to an integer. This query would return true or false if the number is in the bounds or not:SELECT ($num >= 2389100000 AND $num <= 2389999999)

Link to comment
Share on other sites

Well I think this time I've deffinetly made it! The link u indicate me saved my life. I haven't used mySQL, but it gave me a good idea.Now, instead of filter_validate_int, I'm using is_numeric() and instead of using the $nat_options I'm imposing the range as a condition.Let me show u the parts I've changed; this will make u understand it better.

if(is_numeric($club[$i]) && ($club[$i] >= 2389100000 && $club[$i]<= 2389999999)){mysql_query("INSERT INTO faf ......}elseif(!is_numeric($club[$i]) || !($club[$i] >= 2389100000 && $club[$i]<= 2389999999)){echo $club[$i] . " is not a valid number";

Thanks a lot again

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...