Jump to content

NArc0t1c

Members
  • Posts

    299
  • Joined

  • Last visited

    Never

Everything posted by NArc0t1c

  1. Bah.. $query = mysql_query($cmd,$c); while($qr = mysql_fetch_assoc($query)) { foreach($qr as $q => $r) { echo "[" . $q . "] => " . $r . "\n"; } echo "\n"; }
  2. You can use the ob_start function in the top of your script to fix header errors.
  3. Try: <?php $str = "from php"; ?> <script> abc = "<?=$str?>" alert(abc); </script> <?php //other code ?>
  4. 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!
  5. 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
  6. Example: <?php echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled' . '<br /> file_get_contents: ', file_get_contents(__FILE__) ? 'Enabled' : 'Disabled'; ?>
  7. 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. (:
  8. 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
  9. You can disable anyone from viewing the pictures but the server. And then whe nthey actually want to share it, copy the image to another location.
  10. 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
  11. 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]
  12. 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
  13. Well, I have discovered a good webhost, for dedicated servers. http://www.theplanet.com , they look very good actually.
  14. 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.
  15. I have actually never gotten an headache from doing php, gotten frustrated, yes. Overall, I think php's current name is perfect, it actually says/defines what exactly it is.
  16. Thankyou, fenway. I will do that.
  17. 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
  18. 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
  19. 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
  20. Eval function maybe? <?php echo eval('echo \'hello\'; '); ?>
  21. 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
  22. No that doesn't work. Thanks anyway..
  23. 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.