Jump to content

miseleigh

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Posts posted by miseleigh

  1. The MySQL manual says that the update statement returns the number of affected rows.  We're trying to figure out how to use that feature, and it seems that few people use it or even think about using it.  The way we've been doing it in the past has been performing the update and then doing a select to get the count.  However, we're trying to reduce the size of our stored procedure (we need it faster!) and combining those into one statement would help.

     

    Any tips on this one?  It's been hard to find anything online.  Basically, in the stored procedure, we want something like

    SET v_count = 
         UPDATE Users 
              SET active=1 
              WHERE username=v_username);

    instead of

    UPDATE Users 
         SET active=1 
         WHERE username=v_username;
    SELECT COUNT(username) 
         INTO v_count 
         FROM Users 
         WHERE active=1 AND username=v_username;

     

     

  2. We're porting over to MySQL from MSSQL, and while trying to create the tables in our new MySQL DB we're getting a syntax error that we can't find.

     

    CREATE TABLE `makem`.`Clients` (
      `cl_ID` INTEGER UNSIGNED NOT NULL,
      `cl_username` VARCHAR NOT NULL,
      `cl_password` VARCHAR NOT NULL,
      `cl_challenge` TINYINT NOT NULL DEFAULT 0,
      `cl_answer` VARCHAR DEFAULT NULL,
      `cl_name` VARCHAR DEFAULT NULL,
      `cl_contact` VARCHAR DEFAULT NULL,
      `cl_phone` VARCHAR DEFAULT NULL,
      `cl_email` VARCHAR DEFAULT NULL
    )
    CHARACTER SET utf8;

     

    It says there's a syntax error near 'NOT NULL'.  If anyone can spot it, please let me know so I can fix it and make my table.  Thanks!

  3. We're trying to pass a link from a child window to the parent window after we upload a file. For some reason, the javascripts below don't even seem to be running, although all the values are filled in correctly after the php is done.  The only thing we can think of is that the child loses its window.opener after processing its own form.  Essentially, the parent calls the child, then the child processes a form to upload a file, and the child is then supposed to fill in a link to that document.

    <SCRIPT type="text/javascript">
    window.opener.document.<?php echo $ret_field;?>.value = "<?php echo $link;?>";
    window.close();
    </SCRIPT>

    The child page uploads eveything properly, but then does not close and does not fill in the value on the parent.  Thanks for any help.

  4. Whoops, I had a typo in there, but it really does all work up to the read() call:

    $sock = socket_create(AF_INET, SOCK_DGRAM, 0);

     

    One possibility I've thought of is that the Ether doesn't know where to send its data back to.  Is there a way to listen to a specific ip address & port number, since I have no way of telling the Ether who's talking to it?

  5. It would be helpful if you could mark which line is line 20, but just giving it a quick glance, you mistyped 'password' in your sql select statement.  Also, you really don't need all those quotes:

    $sql="SELECT email, password FROM sign WHERE email = $email AND password = $password"; would work.

  6. I'm using UDP sockets to talk to an Ether IO 24 board, and I need to make my commands get through properly, so I'm trying to read back the data I send to it.  However, I'm not getting anything, and instead my browser just hangs.  I don't know much about sockets (this is my first time using them) so maybe there's something I should be doing that I'm not or vice versa.  Any help would be greatly appreciated.

     

    set_time_limit(0);
    $socket = socket_create(AF_INET, SOCK_DGRAM, 0);
    $result = socket_connect($sock, $IP, $Port);
    
    $cmd = pack("ci", $writeA, $xff);    // writes to device - this works
    socket_write($sock, $cmd);
    $cmd = pack("c", $readA);    // tells device to send data back
    socket_write($sock, $cmd);
    
    $buf=socket_read($sock, 2);    // I get nothing here
    echo $buf;

  7. I need to create strings with escape hex numbers - I'm trying to use sockets to write to a device that needs binary values.  If I use a single string like "\x8" it does exactly what I'm looking for, but putting the 8 into a variable and appending them doesn't work properly.  Any tips?

     

    $hex1 = "\x8";
    socket_write($socket, $hex1);   //this works!
    
    $hex = 8;
    $hex2 = "\x".$hex;
    socket_write($socket, $hex2);   //this one doesn't, but I need to be able to do this.
    

     

    I've also tried $hex2 = '\x'.$hex and $hex2 = "\x$hex".  Neither worked.  Any help would be awesome.

  8. Also, those ssh commands are through putty's plink utility, with commands for the router we're linking to piped in from a text file.  Maybe it's something with plink not waiting for the router's prompt before sending the piped-in commands when it's being run through Apache?  I can't think what Apache would do to change this, though, the same batch file works fine when double-clicked.

  9. I'm trying to run a .bat file through php.  The exec command works just fine if I use the CLI version of PHP, but doesn't work right if I run it through Apache.  (It kind of works - I can get solitaire to run, but not a batch file containing SSH commands.  Though that batch file runs fine if I double-click it.)

     

    So it looks like there's a permissions issue with Apache.  Any tips where to look for this?

  10. Yet another update... this is really bugging me now.

     

    exec is partly working, but not fully.  Doing an exec command on a process like solitaire or calculator does create a process, but the window won't pop up - it seems to get hung right after the process is started but before it really gets going.  It's probably not a php issue like I thought it was, but I'm still hoping someone here can help because I really don't know where else to go.  We've been working on this for a few days now and haven't gotten anywhere.

     

    Thanks for any help/advice you can offer.

  11. We're using php to run batch files that create an ssh connection (using PuTTY) into routers and run various commands on those routers.  At least, that's what we're trying to do, but somewhere along the way the commands for the router get partially lost.

     

    The code that creates & executes the batch file:

    $cmd.="$cmd="set PATH=D:\Program Files\PuTTY;%PATH%\r\n";
    plink $rt -ssh -l $un -pw $pw < $script\r\n"; //plink is the putty connect command
    //$rt is the router's ip, $script is a file holding the ssh commands for the router
    $bat=$folder."putty.bat";
    $fp=fopen($bat, 'w');
    fwrite ($fp, $cmd);
    fclose ($fp);
    exec ($bat." >> ".$out);

     

    The batch file is exactly what we need it to be, and works well when you double-click it.  However, when run through exec... basically, the first half of the router commands in the $script file get cut out.

    The .bat file (which works perfectly on it's own, btw): ($bat, above)

    set PATH=D:\Program Files\PuTTY;%PATH%
    plink ipaddress -ssh -l username -pw password < routerfile.txt

    And then routerfile.txt:

    enable

    config

    remote configuration radius

    interval 43200

    end

    end

    quit

    And the output (from the $out file in the exec command):

    prompt>set PATH=path

    prompt>plink ipaddress -ssh -l username -pw password  0<C:/OpenSA/Apache2/MMW_Includes/SSH/interval720.txt

    ation radius

    interval 43200

    end

    end

    quit

     

    MSC-3200 V. 3.1.1.5-03-4687

    © 2005 Colubris Networks Inc.

    CLI> ation radius

    % Unknown command.

    CLI> interval 43200

    % Unknown command.

    CLI> end

    % Unknown command.

    CLI> end

    % Unknown command.

    CLI> quit

    (where CLI> is the router's prompt.)

    As you can see, the router isn't receiving "enable config remote configur" when it should, but again this is only when we run the batch file through exec.  I've also tried using system instead of exec, with the same results.

    The only things I've been able to think that might do this would be overrunning a buffer somewhere, or maybe it's not waiting for the router's prompt before it starts sending commands, or there's an Apache or PHP configuration issue.

     

    I would love some help if anyone knows what's going on here, or at least has some suggestions for where to look.  Thanks.

  12. Well, I know the module should work, but it looks like the module isn't getting a function from one of the windows .dlls that it expects, and I just can't get it to load that way.  ("Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.")  I might be able to fix that if I could figure out which module is causing the problem, but I haven't been able to.

     

    So back to this.  You're saying that loading a module in through the CLI doesn't affect Apache at all, even if I run it through Apache, so I'll have to write my ssh functions as CLI scripts?  Is there a way I can get the results back from those scripts that way?

×
×
  • 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.