Jump to content

shams

Members
  • Posts

    76
  • Joined

  • Last visited

Everything posted by shams

  1. When i run this code: <?php $bar = 'BAR'; apc_store('foo', $bar); var_dump(apc_fetch('foo')); ?> get this error: PHP Fatal error: Uncaught Error: Call to undefined function apc_store() This is phpinfo() for apcu: APCu Support Enabled Version 5.1.21 APCu Debugging Disabled MMAP Support Enabled MMAP File Mask no value Serialization Support php Build Date Jan 4 2022 17:27:51 Directive Local Value Master Value apc.coredump_unmap Off Off apc.enable_cli Off Off apc.enabled On On apc.entries_hint 4096 4096 apc.gc_ttl 3600 3600 apc.mmap_file_mask no value no value apc.preload_path no value no value apc.serializer php php apc.shm_segments 1 1 apc.shm_size 32M 32M apc.slam_defense Off Off apc.smart 0 0 apc.ttl 0 0 apc.use_request_time Off Off
  2. +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ 2 rows in set (0.00 sec) from the terminal can add the user to mysql as root.
  3. In ubuntu 19.04 with php version 7.2 , i want to add mysql user with php when i run the code below get the error: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' I didn't set any password for root , this is php code: <?php $server = "localhost"; $dbuser = "root"; $dbpassword = ""; try { $connection = new PDO("mysql:host=$server", $dbuser, $dbpassword); $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $user = 'test' . '@' . 'localhost'; $sqlQuery = "CREATE USER . $user . "; $connection->exec($sqlQuery); echo "User created successfully!"; } catch(PDOException $e){ echo $sqlQuery . "<br>" . $e->getMessage(); } $connection = null; ?>
  4. I want to pass the variable $host to the php script: The above script didn't get the variable $host, with this error of apache log:
  5. This is the output: This is the apache error.log:
  6. I tried the all 3 above lines one by one and no one work and this is the script i run: and these are the errors from apache log for the all 3 above lines one by one:
  7. I want to use with ssh but it didn't get the variable: and get this error:
  8. Thanks for reply, i want to use the variable inside the exec function not for the echo but for ssh just for easy i use the echo command inside the exec function, I will use your script to edit for my need. Sorry for the inconvinence.
  9. I want to get the values of variables from html form and then pass to the command of exec function in the php script, but it is not working:
  10. What i exactly want to create sript for, it's a problem to run the above command for every site i open in the linux terminal so i want to create a html form and php script with the input field for the url of site i want to open and a submit button, when i inter the site url in the forum input field and hit the submit button the php script should do all the rest and open the site in the new tab of firefox, i don't have much knowlegde in html and php coding so started to go step by step. I aso created the socks proxy but that is slow so i preffer this one.
  11. Yes i want to use my shell server as proxy and forward my web traffic, but the above command working from the linux terminal and i can open localhost:9001 this is the output from terminal:
  12. I watch the log that says the connection established, but there is no tunnel because localhost:9001 is not working, this is log:
  13. The auth is now with rsa keys, this is the new command: the output now is: any help please?
  14. Thanks for reply, can you help how i can check the output?
  15. I want to create a ssh tunnel with php script but it is not working: just print the Done.
  16. With the running code below msmtp send the empty email to the reciepient without any subject, From, To and message (body) : <?php $from = $_POST['from']; $To = $_POST['To']; $subject = $_POST['subject']; $message = $_POST['message']; $account = $_POST['account']; ob_start(); echo "Subject:\n".$subject."\n To:".$To."\n From:". $from."\n\n".$message; $str = ob_get_contents(); ob_end_clean(); exec("echo $str | msmtp --account=$account -f $from $To"); ?> Didn't get all the values from the echo command, any help please?
  17. hi, i can display the current mysql database and user name with this query: mysql> select databse(), user(); how i can print the output of this query with a php script?
  18. hi, i have lcoal webserver for my domain, i can open my domain without problem, i added the virtual host when i try to open them this is the error: Forbidden You don't have permission to access / on this server. DocumentRoot is the /home/user/www/html/htdocs and the permissions are set to 755 with the same permissions  my domain is working, any one can help please?
  19. hi, this is a mysql query shows the rows of table pharmacy with columns id,Code,Name ,Exp (the drug expiry date)and ExpLeft (Expiray Left for the drugs in months) for the drugs, the query is working fine without (WHERE ExpLeft='$ExpLef'), i want to query for the column ExpLeft for exmple for the drugs EcpLeft is 12 months, the code is not working with the query WHERE , there is no any error in ouput just shows the table headers. [code] <html> <head> <title>Open Pharmacy</title> <style type="text/css"> table tr td { font: 12px Verdana, Arial, sans-serif; text-align: center; font-weight: bold; } table tr th { font-size: 12px; text-align: center; } </style> </head> <body> <?php include 'library/config.php'; include 'library/opendb.php'; include 'library/paging_function.php'; $ExpLef = $_POST['ExpLef']; // query the table $result = mysql_query("SELECT count(*) FROM pharmacy"); $total = mysql_result($result, 0); $news = mysql_query("SELECT * FROM pharmacy WHERE ExpLeft='$ExpLef' ORDER BY id ASC LIMIT $start, $display"); echo "<table border='1'>"; echo "<tr><th>Id</th><th>Code</th><th>Name</th><th>ExpLeft</th></tr>"; while($row = mysql_fetch_assoc($news)) { // Expiray Left in Months $Exp = $row[Exp]; $expires=strtotime($Exp); $rightnow=time(); $secondsleft=$expires-$rightnow; $ExpLeft=round($secondsleft/2592000); echo "<tr><td>"; echo $row[id]; echo "</td><td>"; echo $row[Code]; echo "</td><td>"; echo $row[Name]; echo "</td><td>"; echo $ExpLeft; echo "</td></tr>"; } echo "</table>"; paginate($display, $pg, $total); include 'library/closedb.php'; ?> </body> </html> [/code][/code]
  20. hi, since days i want to try pagination of mysql query from a hospital database but no success i tried many codes from the web,  this  is a code but the links are not working or say there is no links there is just a printed text in the links: <?php // Make a MySQL Connection // Connects to your Database include 'library/config.php'; include 'library/opendb.php';     $limit          = 2;                  $query_count    = "SELECT count(*) FROM pharmacy";        $result_count  = mysql_query($query_count);        $totalrows      = mysql_num_rows($result_count);     if(empty($page)){         $page = 1;     }             $limitvalue = $page * $limit - ($limit);     $query  = "SELECT * FROM pharmacy LIMIT $limitvalue, $limit";            $result = mysql_query($query) or die("Error: " . mysql_error());     if(mysql_num_rows($result) == 0){         echo("Nothing to Display!");     }     $bgcolor = "#E0E0E0"; // light gray     echo("<table>");     echo ("<tr><th>Id</th><th>Code</th></tr>");         while($row = mysql_fetch_array($result)){         if ($bgcolor == "#E0E0E0"){             $bgcolor = "#FFFFFF";         }else{             $bgcolor = "#E0E0E0";         }     echo("<tr bgcolor=".$bgcolor."><td>");     echo($row["id"]);     echo("</td><td>");     echo($row["Code"]);     echo("</td></tr>");     }     echo("</table>");     if($page != 1){         $pageprev = $page--;                 echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> ");     }else{         echo("PREV".$limit." ");     }     $numofpages = $totalrows / $limit;         for($i = 1; $i <= $numofpages; $i++){         if($i == $page){             echo($i." ");         }else{             echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");         }     }     if(($totalrows % $limit) != 0){         if($i == $page){             echo($i." ");         }else{             echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");         }     }     if(($totalrows - ($limit * $page)) > 0){         $pagenext = $page++;                 echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>");     }else{         echo("NEXT".$limit);     }         mysql_free_result($result); ?> this the ouput in simple text with on links to click: Id Code 1 23uy 2 gz78 PREV2 1 NEXT2
  21. hi, since days i am trying codes for pagination but failed to edit for my own query this is a mysql query can any one please put in paging code: [code] <?php // Make a MySQL Connection // Connects to your Database include 'library/config.php'; include 'library/opendb.php'; $query = "SELECT * FROM pharmacy"; $result = mysql_query($query) or die(mysql_error()); echo "<table border='1'>"; echo "<tr><th>Id</th><th>Code</th><th>Name</th></tr>"; while($row = mysql_fetch_array($result)){ echo "<tr><td>"; echo $row[id]; echo "</td><td>"; echo $row[Code]; echo "</td><td>"; echo $row[Name]; echo "</td></tr>"; } echo "</table>"; include 'library/closedb.php'; ?> [/code] The paging should have links like  this: [code] <<First <Previous Page 2 of 30 Next > Last>> [/code] [/code]
  22. hi, i am loging as user to my pc runing fc5, i wrote a cgi script as root from a terminal using su in the /var/www/cgi-bin and i made it executable with chmod u+x, now when i want to execute this script from the cgi-bin as http://localhost/first.pl this is the error: Forbidden You don't have permission to access /first.pl on this server. after this error i changed the ownership of cgi-bin and the script to my user name but even after that this is the error message, the serve runing apche. and this is the apache error log; [Mon Oct 30 16:56:16 2006] [error] [client 127.0.0.1] Premature end of script headers: first.pl [Mon Oct 30 16:59:56 2006] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /var/www/html/first.pl and this is the script: #!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello, World."; any one can help please?
  23. hi, i have local server, the doument root is /var/www/html in fc5 the localhost is runing ok, there is other users runing php scripts, how i can configure apache for this users to run thier php scripts  from their own directories in localhost while they are offline? thankd in advanced for your help.
  24. thanks to all for replies, as i menttioned the drug_col is same as $drug, i means $drug is the column name as well the drug name, each indivdual query work fine, but don't know how to combine them in one php code.
  25. hi, i have the patients mysql table name is treatment, patients will collect thier drugs each month in the same date, it means for each patiens will be multiple entries with deferent id's because the id is auto_increment, ecach drug has it is own column, so the quantity will be entered in the ecah drugs column, i will enter the drug name and the months for that drug will be taken by the patients, this script will tell me the quanttity of that drug i need for the future: [code] <?php $drug = 'PZA'; #$_POST['drug']; $months = '4'; #$_POST['type']; mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("mydb") or die(mysql_error()); $result = mysql_query("SELECT SUM($drug) as total FROM treatment"); $total = mysql_result($result, 0, 'total'); $no = mysql_query("SELECT count($drug) FROM treatment"); $newtot = (($total/$no)*$months) - $total; if($newtot) { echo "You need ".$newtot." " ."tab of " .$drug; } else { echo "Sorry no match found"; } ?> [/code] but the output of this script is sorry no match found which is not the correct answer, any one can help please?
×
×
  • 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.