Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    php file not found error mysql socket?

    This code shows the files listed for ./
    As you can see it shows the file test.php

    Code:
        $dir    = './';
        $files1 = scandir($dir);
        print_r($files1);
    
        Array
        (
        [0] => .
        [1] => ..
        [2] => xxx.php
        [3] => xxx.php
        [4] => xxx.php
        [5] => test.php
        [6] => xxx.html
        [7] => .htaccess
        [8] => index.php
        [9] => license.txt
        [10] => xxx.html
        [11] => xxx.php
        [12] => xxx.html
        [13] => xxx.jpg
        [14] => xxx.xml
        [15] => xxx.xml.gz
        [16] => xxx
        [17] => wp-activate.php
        [18] => wp-admin
        [19] => wp-blog-header.php
        [20] => wp-comments-post.php
        [21] => wp-config.php
        [22] => wp-config-sample.php
        [23] => wp-content
        [24] => wp-cron.php
        [25] => wp-includes
        [26] => wp-links-opml.php
        [27] => wp-load.php
        [28] => wp-login.php
        [29] => wp-mail.php
        [30] => wp-settings.php
        [31] => wp-signup.php
        [32] => wp-trackback.php
        [33] => xmlrpc.php
        )
    However, when I run the script, it gives an error file not found:

    Code:
        echo "Running test...<br />";
        $filename = './test.php';
        require $filename;
    Running test...
    error: No such file or directory

    It gives the error but it has actually run the SQL code inside of the include file.
    I can't figure out why this is happening. I do not have any other require commands in either of the 2 files.
    The SQL is stored in a DB and runs from a plugin "Wordpress include PHP in posts"
    Could this be changing the paths somehow? It seems strange that it would run the include command but then show a file not found error.

    thispage suggests it's the mysql socket: stackoverflow.com/questions/1676688/ but that doesn't make sense either because it is running all the SQL code inside the required file

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    There is nowhere near enough information here.
    Post the code in test.php.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    There is nowhere near enough information here.
    Post the code in test.php.
    here it is

    Code:
    <?php
    
    if (isset($_GET["vpnadd"]) || isset($_GET["proxyadd"])) {} else {exit();}
    
    			$squid_cust = $_GET["vpnadd"];
    			$squid_email = $_GET["vpnaddemail"];
    			$squid_date_purchased = $_GET["vpnadddate"];
    			
    function senderroremail() {
    	mail('sales@mysite.com', 'AddOrders script error', mysql_error().' error');
    	die('Error: ' . mysql_error());	
    }
    
    //conn 2
    $squid_conn_remote = mysql_connect("xxx",
    	                            "xxx",
    	                            "xxx");
    	if (!$squid_conn_remote) 	  {echo 'Error on line: ' . __LINE__;senderroremail();}
    
    //function
    function generatePassword($length=6,$level=2){
    
       list($usec, $sec) = explode(' ', microtime(false));
       srand((float) $sec + ((float) $usec * 100000));  
    
       $validchars[1] = "23456789abcdefghjkmnpqrstuvwxyz";
       $validchars[2] = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
       $validchars[3] = "23456789_!@#$%&*()-= /abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ_!@#$%&*()-= /";
    
       $password  = "";
       $counter   = 0;
    
       while ($counter < $length) {
         $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
    
         // All character must be different
         if (!strstr($password, $actChar)) {
            $password .= $actChar;
            $counter++   ;
       }
       }
    
       return $password;
    
    }
    
    if (isset($_GET["vpnadd"])	)
    
    	{
    		mysql_select_db("squid", $squid_conn_remote);
    					
    		$squid_result = mysql_query('SELECT customers_id, products_id FROM table1_wp WHERE customers_id = '.$squid_cust.'				     
    		',$squid_conn_remote) or die(__LINE__);
    		$row = mysql_fetch_row($squid_result);
    		$prod = $row[1];		
    		$squid_prod = mysql_query('SELECT Equivalent FROM ProductMapping WHERE WPProduct = '.$prod.'				     
    		',$squid_conn_remote) or die(__LINE__);
    		$row = mysql_fetch_row($squid_prod);
    		$equivprod = $row[0];		
    
    		if (mysql_num_rows($squid_result) > 0)
    		{
    
    			$squid_update = mysql_query("
    					UPDATE table2_wp 
    					SET enabled = 1, 
    					OrderDate = '".$squid_date_purchased."',
    					products_id = ".$equivprod.",
    	      UpdateOnNextCycle=1,
    	      DataTakenByScript=0
    					WHERE customers_id = ".$squid_cust."
    					AND (DataTakenByScript=0
    					OR OrderDate <= DATE_SUB( NOW( ) , INTERVAL 1 DAY ))				     
    			",$squid_conn_remote) or die(senderroremail());
        if (mysql_affected_rows() > 0 ) {mail('sales@mysite.com', 'Swap Order now added', 'Swap Order now added '.$squid_email);}    
        
    		}
    
    		else 
    		{	
    		//if the customerid is not in the database, insert a row
    			$pos = strpos($squid_email, '@');
    			$squid_user = substr($squid_email, 0, $pos);
    			$squid_checkname = mysql_query("SELECT user FROM table2_wp WHERE user ='".$squid_user."'",$squid_conn_remote);
    			if (mysql_num_rows($squid_checkname) == 0)
    			{
    				$squid_insert = mysql_query("
    				INSERT INTO table2_wp (user, enabled, customers_id, OrderDate, products_id, UpdateOnNextCycle, email_address) 
    				VALUES ('".$squid_user."', 1, ".$squid_cust.", '".$squid_date_purchased."', ".$equivprod.", 1, '".$squid_email."')			     
    				",$squid_conn_remote);
    	     if (!$squid_insert) {echo 'Error on line: ' . __LINE__;senderroremail();}
    	     if (mysql_affected_rows() > 0 ) {mail('sales@mysite.com', 'Swap Order now added', 'Swap Order now added '.$squid_email);}
    
    			}
    			else
    			//so, change the username and add the customerid, which will make it unique
    			{
    				$squid_user = $squid_user.$squid_cust;
    				$squid_insert = mysql_query("
    				INSERT INTO table2_wp (user, enabled, customers_id, OrderDate, products_id, UpdateOnNextCycle, email_address) 
    				VALUES ('".$squid_user."', 1, ".$squid_cust.", '".$squid_date_purchased."', ".$equivprod.", 1, '".$squid_email."')			     
    				",$squid_conn_remote);
    	      if (!$squid_insert) {echo 'Error on line: ' . __LINE__;senderroremail();}
    	      if (mysql_affected_rows() > 0 ) {mail('sales@mysite.com', 'Swap Order now added', 'Swap Order now added '.$squid_email);}
    			}
    		}
    
    			
    	}
    
    		mysql_close($squid_conn_remote);
    ?>

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I'm not seeing where you generate this error output, so I'm going to assume that its simply your own typing of an internal error which is *probably* a failed to open stream error.

    What you need to do is verify this as being the cause. The error you posted itself doesn't match an actual internal error, but the description does for a failed import. It would also include information on what file was failed and on what line and file it was attempted to include. If it doesn't include this, this is a custom error that's generated which does not appear to be a part of this code.

    If this were an error with your SQL it would make it very clear that this is a SQL error.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    any ideas?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You'll need to check your actual error; you can look for the error log associated with site. File and line number are included as a part of the stack, so if I had to guess your actual error is a stream error (ie: failed to open stream) when trying to use an include/require in PHP. This would likely be caused by an inclusion which is changing the nesting location; PHP imports based on the EXECUTING script, not the script for inclusion. So you can run one script flawlessly, and then attempt to import it into a different script in a different filepath and it won't function properly. This is why either absolute paths (not recommended) or relative from THIS script are your best options for include/require importing. I don't recommend using document root since that's only available in a server environment (ie: you cannot use php directly on cron).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    New Coder
    Join Date
    Dec 2007
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    the current coe uses a relative path.
    the odd thing is that it's running the sql code that is in the included file.
    this link shows some mysql errors with the error:No such file...
    https://www.google.com/search?q=erro...rectory++mysql

    It's like it's not related to a missing file at all.

    if I turn on error_reportin, still nothing appears.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Check your error logs.
    Otherwise, you'll need to track down where that error is tossed, it could simply be due to insufficient information in the output for it. Like I said, the error itself is not a standard built in one but the description does match that of a stream error, not a mysql one.
    Also note that I specifically said relative from THIS script, not relative.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •