Jump to content

NArc0t1c

Members
  • Posts

    299
  • Joined

  • Last visited

    Never

Posts posted by NArc0t1c

  1. you missed out the semi-colin

    <?php
    $str="from php";
    ?>
    <script>
    var abc="<?php echo($str) ?>";
    alert(abc);
    </script>
    <?php
    ?>

     

    Many programmers continue this habit when writing JavaScript, but in general, semicolons are  optional! However, semicolons are required if you want to put more than one statement on a single line.

  2. Hello.

     

    I'm trying to make a script that will show all rows and columns in the specific table.

    It is actually sort of alike a tutorial, to test your mysql queries.

     

    I have different about of column's in each table, as well as rows.

    My question is, how can I Do this, phpMyAdmin has a perfect example of this, but how can I do this?

     

    My current scripting for this is the following:

    $c = mysql_pconnect('localhost','root','');
    while($qr = mysql_fetch_assoc(mysql_query($cmd,$c))) {
    foreach($qr as $q => $r) {
    		echo '[' . $q . '] => ' . $r . '<br>';
    }
            echo "\n";
    }
    

     

    The problem with that is, it shows the first row, but repeats in for an infinity.

    Also please note that it should not use any html elements, because I would like it to be run trough the php executable.

    The output should be similar to:

    [id] => 1
    [name] => John
    [last] => Doe
    
    [id] => 2
    [name] => Jane
    [last] => Doe

     

    Thanks!

  3. I'm currently busy with a project that involves the usage of a graph.

    I store timestamp in a database, and then work out the average of it, and then with a loop, show the correct amount.

    It's currently show all as zero, which is incorrect.

    Here is my script.

    <?php
    
    // create image
    $image = imagecreate(480,120);
    
    // allocate some solors
    
    $white    = imagecolorallocate($image, 0xFB, 0xFB, 0xFB);
    $black    = imagecolorallocate($image, 0x00, 0x00, 0x00);
    $gray     = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
    $darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);
    $navy     = imagecolorallocate($image, 0x00, 0x66, 0xCC);
    $darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);
    $red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);
    $darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);
    $whites  = imagecolorallocate($image, 0x20, 0x28, 0x3E);
    imagefill($image,0,0,$white);
    imageline($image,5,105,475,105,$black);
    $s = 0;
    $list = 0;
    $c = 0;
    $ps = 1;
    $chars = array(' 1', ' 2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24');
    for($i=20;$i<=720;$i+=20){ 
    imageline($image,$i,105,$i,115,$black);
    imagestring($image, 2, $i-15,105,$chars[$c],$black);
    $c++; 
    $ps++;}
    function add($s,$num){
    global $image, $whites;
    $num = (100-$num);
    for($a=$s;$a<$s+10;$a++) imageline($image, $a,104,$a,$num,$whites);
    }
    $mc = mysql_connect('127.0.0.1:3306','root','');
    mysql_query('USE db');
    $id = $_SESSION['login'];
    $x = 0;
    for($i=1;$i<=24;$i++) {
    $qy = mysql_query("SELECT AVG(hour) FROM activity WHERE empid='$id' AND hour='$i'");
    add($x+5, mysql_result($qy,0));
    $x += 20;
    }
    header('Content-type: image/png');
    imagepng($image);
    imagedestroy($image);
    ?> 

     

    Thanks in advance.

    Ferdi

  4. Ahh, Orio beat me to it, here is mine anyway.

    Well so you want the array in two halves?

     

    Try this.

    <?php
    
    $sql = "SELECT * FROM table  WHERE var = ".$string."";
    $result = mysql_fetch_assoc($obj_db->select($sql));
    $number = 0;
    $first = array();
    $end = array();
    foreach ($result as $r) {
    while ($number <= (count($result)/2)) {
    $number++;
    $first[] = $r; }
    while($number > (count($result)/)) {
    $number++;
    $end[] = $r; }
    }
    
    ?>
    

    I don't know if it will work, but theory is there. (:

  5. Thank you, if I am getting your theory correctly, it should work if I point it to the dll(python24.dll).

     

    But it still does not, here is my output for checking.

    C:\wamp\Apache2\bin>httpd -t
    httpd: Syntax error on line 117 of C:/wamp/Apache2/conf/httpd.conf: Can't locate API module structur
    e `python_module' in file C:/wamp/Apache2/bin/python24.dll: No error
    

     

     

    Thanks.

    Ferdi

  6. Well, the contents within the file, is what I see when trying to access it.

    I know it won't work with it commented, I forgot to uncomment it when I uploaded it.

     

    Well, I tried the syntax checking with httpd, and here is what I get.

    C:\wamp\Apache2\bin>httpd -t
    httpd: Syntax error on line 117 of C:/wamp/Apache2/conf/httpd.conf: Cannot load C:/wamp/Apache2/modu
    les/mod_python.so into server: The specified procedure could not be found.
    
    C:\wamp\Apache2\bin>

    I read on modpython the website, in their FAQ they said to try and move pythonx.dll out of the windows dictionary, I tried that with no luck.

     

    Thanks so var.

    Ferdi

  7. Hello there,

     

    I have recently installed python, Did all the instructions as needed, step by step.

    I had to rewrite my old httpd.conf, or did I?

    Well, apache's error log isn't giving much about this, so I cannot get any information on what is causing this.

    I have tried the config file with the python mod commented, and still nothing.

     

    I have meanwhile re-installed apache2, it now works, but it's without the python module.

    I have tried to edit my httpd.conf file, but still nothing.

    Here is my config file(httpd.conf).

    Attachment.

     

    Thanks in advance.

     

    [attachment deleted by admin]

  8. Hello.

     

    Basically what I am trying to do is have a textbox that would have an image in it.

    I have that part done, but what can I use to move the starting point of the text?

    Example:

    ____________

        Start Here |

     

    This is my current script:

    <html>
    <head>
    <style type="text/css">
    body {
      background-color: #FFF;
      color: #00;
      font-family: Tahoma;
      font-size: 12px;
    }
    input {
      border: solid;
      border-color: #CCC;
      border-width: 1px;
      height: 20px;
      color: #ccc;
    }
    input:focus {
       border-color: #333;
       color: #333;
    }
    .input_name {
      background: url(input_name.jpg);
      background-repeat: no-repeat; 
    }
    .input_key {
      background: url(input_key.jpg);
      background-repeat: no-repeat; 
    }</style>
    </head>
    <body>
    <form>
    <input type="text" class="input_name">
    <input type="text" class="input_key">
    </form>
    </body>
    </html>
    

     

    Thankyou in advance.

    Ferdi

  9. Well, it depends if the server i'm uploading to supports multiple ftp sessions.

    if it does, I use 3D-FTP, very fast for uploading small scripts/things.

    if it does not, then I call upon SmartFtp. :)

  10. That's impossible to do with the RAND() function alone... it can only take a seed for the random number generator.

     

    You'd need to "group" them into bins, then pick a random one from the highest "bin".

    Thankyou, fenway.

     

    I will do that.

  11. I changed my script;

    <?php
      define("MYSQL", "TRUE");
      require("mysql_db.php");
      if (isset($_POST['email']) && isset($_POST['password'])) {
          $email = htmlspecialchars(strip_tags($_POST['email']));
          $passwd = htmlspecialchars(strip_tags($_POST['password']));
          $passwd = md5($passwd);
          $query = mysql_query("SELECT mid,m_email,m_password FROM members WHERE m_email='$email' AND m_password='$passwd'", $connect);
          if (mysql_num_rows($query) < 1)
              echo 'Invalid Username/Password.';
          else {
              $data = mysql_fetch_array($query);
              $cookie = setcookie("GA_login", $data['mid'] . ":" . $data['m_email'] . ":" . $data['m_password'], time()+43200000);
              if (!$cookie)
                  echo 'Please enable cookies.';
              else
                  echo $_COOKIE['GA_login'] . 'Login Done.';
          }
      }
      else echo 'Yes..\?';
      mysql_close($connect);
    ?>
    

     

    Seems to be working now, I think it was my path/host.  ::)

    Thanks

    Ferdi

  12. Hello.

     

    I have a login page, actually it is a page that calls the login page trough ajax.

    I am having a problem, the login cookie is not being created by the php script.

    I do the validation with php and javascript, here is a example of how data gets sent.

    [pre]

      Javascript <- Ajax Receives <- PHP Script <

    (                                            )

      > HTML -> Javascript Validation -> Ajax Sends

    [/pre]

    Well, In theory it should work, but I can't find any reason why the cookie is not being created.

     

    Here is my script, sovar;

    <?php
      define("MYSQL", "TRUE");
      require("mysql_db.php");
      if (isset($_POST)) {
          $email = htmlspecialchars(strip_tags($_POST['email']));
          $passwd = htmlspecialchars(strip_tags($_POST['password']));
          $passwd = md5($passwd);
          $query = mysql_query("SELECT mid,m_email,m_password FROM members WHERE m_email='$email' AND m_password='$passwd'", $connect);
          if (mysql_num_rows($query) != 1)
              echo 'Invalid Username/Password.';
          else {
              $data = mysql_fetch_array($query);
              $cookie = setcookie("GA_login", $data['mid'] . ":" . $data['m_email'] . ":" . $data['m_password'], time() + 3155760000,"/",$_SERVER['HTTP_HOST']);
              if (!$cookie)
                  echo 'Please enable cookies.';
              else
                  echo $_COOKIE['GA_login'] . 'Login Done.';
          }
      }
      mysql_close($connect);
    ?>
    

     

    Any help on this?

    Ferdi

  13. Hello.

     

    I'm sitting here with a problem I cannot seem to pass.

    What I am trying to do is select data from row, ordered by it's rank.

    So, that means, the higher the rank, the more likeley it will be picked.

    Here is my query sofar;

    select `id`,`name`,`image`,`url`,`mid`,`status` FROM `people` where `status`='1' order by rand(`rank`) limit 1

     

    I have read the mysql documentation of the rand function, but I don;t know/can't find info on this.

    Is it maybe that it can only handle numbers, if so, won't it return a number in any case.

    The type of `rank` is int and set to 10 characters.

     

    Edit: Oh yes.., the error; #1210 - Incorrect arguments to RAND

     

    I really need help on this.

    Thanks

    Ferdi

  14. Hey..

     

    I'm trying to make something for someone, this requires the server, using a crontab to make a backup of all the files, and maybe also the mysql database.

     

    I thought I will use Zip to archive the files/dictionaries, and then upload it to another remote ftp server.

    I have the Ftp working, it makes connection and sends files.

     

    But here comes my problem, how can I zip the files, and the dictionaries?

    It would require a check to see if it is a dir, if it is, then loop trough that dir and upload those files.

    How can I achieve this?

     

    Here is a script I tried to make to just upload the files via Ftp, This is creating dictionaries and the root files, btu not uploading the files within the sub folders.

     

    <?php
    
    
    
    $FtpServer = 'server';
    $FtpPort = 21;
    /* Password and user comes here.. */
    $FtpDir = '/narc0de/';
    $dir = 'c:\wamp\www\ziptest\narc0de';
    $Stream = ftp_connect($FtpServer, $FtpPort,60);
    $Login = ftp_login($Stream, $FtpUser, $FtpPasswd);
    if (!$Login || !$Stream){
    	echo 'Login or Connection Failed.';
    	exit; }
           if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false ) { echo $file; $i++;
                           if( $file != "." && $file != ".." )
                           { $nowd = ftp_pwd($Stream);
                             $Do = ftp_put($Stream, $file, $nowd.$file, FTP_BINARY); } }
                   closedir($dh); } }
    
    if (isset($Do)){
    	echo 'Uploaded backup.'.$i;
    }
    else {
    	echo 'Upload Failed.';
    }
    ftp_close($Stream);
    exit;
    
    ?>
    

     

    Thanks

    Ferdi

  15. Hello..

    I'm trying to build an application that you will be able to replace things within a php file.

    I have built it, but I have a problem, it is not doing what it is supposed to.

     

    I have two array's, One with all the things that it should search for, and then one array that should be used for replacing.

    Here is a same:

    <?php
    $Search = array('<?pgp', ' <?php'); // 22 to be exact.
    $Replace = array('<?php', '<?php'); // 22 to be exact.
    ?>

     

    Well, I don't know if that is working or not, I suppose it is.

    The function I use for replacing is str_replace, It should search an array, and return the results as an array or string.

    Well, It's not doing either.

    Here is my script:

    <?php
    $Search = array('<?pgp', ' <?php'); // 22 to be exact.
    $Replace = array('<?php', '<?php'); // 22 to be exact.
    if (isset($_POST['submit'])){
       $Random = md5(time()/rand(1,100)); // This would be the name of the file, I changed to test for this purpose.
       $Handle = fopen('attachments/test.txt', 'w+');
       fputs($Handle, $_POST['code']);
       fclose($Handle);
       $File = file('attachments/test.txt');
       $Files =  str_replace($Search, $Replace, $File);
       $Handle = fopen('attachments/test.txt', 'w+');
       foreach ($Files as $Lines){
       fputs($Handle, $Lines); }
       fclose($Handle); 
    }
    ?>

    I have cut it down and things but that is the principle it goes by.

    It's writing and things, but it would return the following in the text file:

    A

    And that's all.

     

    Anyone see anything I may be doing wrong?

    I have looked at the preg_replace function aswell, it did the same.

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