Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 78/1708 | < Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >

  • trying to backup mysql database using php

    - by user225269
    I got this code from this site: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx But I'm just a beginner so I don't know what the config.php and opendb.php suppose to mean. Do I have to create those 2 files in order for this code to work? If yes, then how do I create it, it isn't included in the site how to create it. <?php include 'config.php'; include 'opendb.php'; $tableName = 'mypet'; $backupFile = 'backup/mypet.sql'; $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName"; $result = mysql_query($query); include 'closedb.php'; ?> can I just include these lines on the top code so that I will not be putting the include 'opendb.php' anymore: $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Hospital", $con);

    Read the article

  • Sanitize input before executing at server in php

    - by Interfaith
    I want to let user input two variable, Name and Password in a form. I want to disable any XSS or script insert in the input values. I have the following code in the form method: <form name="form1" method="post" action="checkpw.php"> Your Name: <table> <tr><td><input class="text" name="name" onBlur="capitalize(this);" maxlength=12 type="text" /></td></tr> </table> Password: <table> <tr><td><input class="text" name="passwd" maxlength=8 type="password" /></td></tr> <tr><td align="center"><br/> <input class="text" type="submit" name="submitbt" value="Login" /> </td></tr> </table> and the following checkpw.php: <?php // Clean up the input values $post = filter_input_array(INPUT_POST, array( 'name' => FILTER_SANITIZE_STRING, 'pw' => FILTER_SANITIZE_STRING, )); if (is_null($post) || in_array(null, $post)) { header("location:login.php"); return; // missing fields (or failed filter) } // pw is the password sent from the form $pw=$_POST['passwd']; $name=$_POST['name']; if($pw == 'testpass'){ header("location:index.php"); } else { header("location:wrong.php"); } ?> Is this a secure way to ensure the form is sent to the server and executed ONLY after the input values have been sanitized? Also, the $name value i want to pass it to index.php file. I insert a code in the index.php as follow: <?php echo $name ?> But it's empty. Any idea how to resolve it?

    Read the article

  • cURL Affects Cookie Retrieval in PHP?

    - by CJ
    I'm not sure if I'm asking this properly. I have two PHP pages located on the same server. The first PHP page sets a cookie with an expiration and the second one checks to see if that cookie was set. if it is set, it returns "on". If it isn't set, it returns "off". If I just run the pages like "www.example.com/set_cookie.php" AND "www.example.com/is_cookie_set.php" I get an "on" from is_cookie_set.php. Heres the problem, on the set_cookie.php file I have a function called is_set. This function executes the following cURL and returns the contents ("on" or "off"). Unfortunately, the contents are always returned as "off". however, if I check the file manually ("www.example.com/is_cookie_set.php") I can see that the cookie was set. Heres the function : <?php function is_set() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://example.com/is_cookie_set.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $contents = curl_exec ($ch); curl_close ($ch); echo $contents; } ?> Please note, I'm not using cURL to GET or SET cookies, only to check a page that checks if the cookie was set. I've looked into CURLOPT_COOKIEJAR, and CURLOPT_COOKIEFILE, but I believe those are for setting cookies via cURL and I don't want to do this.

    Read the article

  • A stupid question about wordpress and php

    - by bubdada
    It may seem stupid question, but i've a serious problem... if you could check out orcik.net the thumbnail images does not appear. I figured out the reason but I don't know how to solve.. http://orcik.net/projects/thumb/orcikthumb.php?src=http://orcik.net/wp-content/uploads/2010/05/mac-safari-search-cache.png If you go to the above link you will get page not found error. However, if you go to the link below you'll get the thumbnail version of the image... http://orcik.net/projects/thumb/orcikthumb.php?src=/wp-content/uploads/2010/05/mac-safari-search-cache.png I'm using this piece of code on wordpress and the line appears like <a href="<?php the_permalink() ?>" rel="bookmark"> <img src="<?php bloginfo('template_directory'); ?>/includes/orcikthumb.php?src=<?php get_thumbnail($post->ID, 'full'); ?>&amp;h=<?php echo get_theme_mod($height); ?>&amp;w=<?php echo get_theme_mod($width); ?>&amp;zc=1" alt="<?php the_title(); ?>" /> </a> Thus, I believe I can't change the directory of image. But I could not figure out why I am getting page not found error. Is that might be CHMOD'es??? or something else?? Thanks

    Read the article

  • php weird bug where an array is not an array !

    - by iko
    I've been going mad trying to figure out why an array would not be an array in php. For a reason I can't understand I have a bug in a smarty class. The code is this : $compiled_tags = array(); for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) { $this->_current_line_no += substr_count($text_blocks[$i], "\n"); // I tried array push instead to see // bug is here array_push($compiled_tags,$this->_compile_tag($template_tags[$i])); //$compiled_tags[] = $this->_compile_tag($template_tags[$i]); $this->_current_line_no += substr_count($template_tags[$i], "\n"); } the error message is Warning: array_push() expects parameter 1 to be array, integer given in .... OR before with [] Warning: Cannot use a scalar value as an array in .... I trying a var_debug on $compiled_tags and as soon I enter the for loop is not an array anymore but an integer. I tried renaming the variable, but same problem. I'm sure is something simple that I missed but I can't figure it out. Any help is (as always) welcomed !

    Read the article

  • function.array-diff problems!

    - by SKY
    Hi, im currently getting these error on my site: Warning: array_keys() [function.array-keys]: The first argument should be an array on line 43 Warning: Invalid argument supplied for foreach() on line 44 Warning: array_diff() [function.array-diff]: Argument #1 is not an array on line 47 Warning: array_diff() [function.array-diff]: Argument #1 is not an array on line 48 And the source are: 42. $tmp = $this->network->get_user_follows($this->user->id); 43. $tmp = array_keys($tmp->followers); 44. foreach($tmp as &$v) { $v = intval($v); } 45. $tmp2 = array_keys($this->network->get_group_members($g->id)); 46. foreach($tmp2 as &$v) { $v = intval($v); } 47. $tmp = array_diff($tmp, $tmp2); 48. $tmp = array_diff($tmp, array(intval($this->user->id))); I want to know what is the problem and how i fix it. Thanks!

    Read the article

  • header location won't work in php

    - by Jayden Kelly
    I am making a login page for my website but the header location won't work. here is the code of login.php: <?php include ( './includes/header.php' ); if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $check_username = mysql_query("SELECT username FROM users WHERE username='$username'"); $numrows = mysql_num_rows($check_username); if ($numrows != 1) { echo 'That User doesn\'t exist.'; } else { $check_password = mysql_query("SELECT password FROM users WHERE password='$password' && username='$username'"); while ($row = mysql_fetch_assoc($check_password)) { $password_db = $row['password']; if ($password_db == $password) { $_SESSION['username'] = $username; header("Location: members.php"); } } } } ?> <h2>Login to Your Account</h2> <form action='login.php' method='POST'> <input type='text' name='username' value='Username ...' onclick='value=""'/><p /> <input type='password' name='password' value='Password ...' onclick='value=""'/><p /> <input type='submit' name='submit' value='Login to my Account' /> </form> I would really appreciate it if someone could help me, thanks. P.S. If you need the php part of the header file it is here: <?php session_start(); include ( './includes/functions.php' ); include ( './includes/connect_to_mysql.php' ); ?>

    Read the article

  • PHP Mail() not working on remote server

    - by Amaerth
    I am developing an application and have been testing the mail() function in PHP. The following works just fine on my local machine to send emails to myself, but as soon as I try to send it from the testing environment to my local machine, it silently fails. I will still get the "Mail Sent" message, but no message is sent. I turned on the mail logging in the php.ini file, but even that doesn't seem to be populated after I refresh the page. Again, the .php files and php.ini files are identical in both environments. Port 25 has been opened on the testing environment, and we are using a Microsoft Exchange server. <?php $to = "[email protected]"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "[email protected]"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> SMTP area of the php.ini file: [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = exhange.server.org ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = [email protected]

    Read the article

  • PHP Session doesn't get read in next page after login validation, Why?

    - by NetStar
    I have a web site and when my users login it takes them to verify.php (where it connects to the DataBase and matches email and password to the user input and if OK puts client data into sessions and take the client to /memberarea/index.php ELSE back to login page with message "Invalid Email or password!") <?php ob_start(); session_start(); $email=$_POST['email']; $pass=md5($_POST['pass']); include("conn.php"); // connects to Database $sql="SELECT * FROM `user` WHERE email='$email' AND pass='$pass'"; $result=mysql_query($sql); $new=mysql_fetch_array($result); $_SESSION['fname']=$new['fname']; $_SESSION['lname']=$new['lname']; $_SESSION['email1']=$new['email1']; $_SESSION['passwrd']=$new['passwrd']; $no=mysql_num_rows($result); if ($no==1){ header('Location:memberarea/index.php'); }else { header("Location:login.php?m=$msg"); //msg="Invalid Login" } ?> then after email id and password is verified it takes them to ` /memberarea/index.php (This is where the problem happens.) where in index.php it checks if a session has been created in-order to block hackers to enter member area and sends them back to the login page. <? session_start(); isset($_SESSION['email'])` && `isset($_SESSION['passwrd'])` The problem is the client gets verified in verify.php (the code is above) In varify.php only after I put ob_start(); ontop of session_start(); It moves on to /memberarea/index.php , If I remove ob_start() It keeps the client on the verify.php page and displays error header is alredy SENT. after I put ob_start() it goes in to /memberarea/index.php but the session is blank, so it goes back to the login page and displays the error ($msg) "Invalid Login" which I programed to display. Can anyone tell me why the session cant pass values from verify.php to /memberarea/index.php

    Read the article

  • Image error with wordpress and php

    - by bubdada
    It may seem stupid question, but i've a serious problem... if you could check out orcik.net the thumbnail images does not appear. I figured out the reason but I don't know how to solve.. http://orcik.net/projects/thumb/orcikthumb.php?src=http://orcik.net/wp-content/uploads/2010/05/mac-safari-search-cache.png If you go to the above link you will get page not found error. However, if you go to the link below you'll get the thumbnail version of the image... http://orcik.net/projects/thumb/orcikthumb.php?src=/wp-content/uploads/2010/05/mac-safari-search-cache.png I'm using this piece of code on wordpress and the line appears like <a href="<?php the_permalink() ?>" rel="bookmark"> <img src="<?php bloginfo('template_directory'); ?>/includes/orcikthumb.php?src=<?php get_thumbnail($post->ID, 'full'); ?>&amp;h=<?php echo get_theme_mod($height); ?>&amp;w=<?php echo get_theme_mod($width); ?>&amp;zc=1" alt="<?php the_title(); ?>" /> </a> Thus, I believe I can't change the directory of image. But I could not figure out why I am getting page not found error. Is that might be CHMOD'es??? or something else?? Thanks

    Read the article

  • inserts 'Array' into mysql table

    - by Noah Smith
    i want to insert an array into a mysql table. The array is produced by script scanning all the links, converting into absolute links and then displaying them in an array. i decided to mysql_query the array into the table but now i am stuck. it only posts 'Array', instead of every row from the array into a different row. Any ideas??! <?php require_once('simplehtmldom_1_5/simple_html_dom.php'); require_once('url_to_absolute/url_to_absolute.php'); $connect = mysql_connect("xxxx", "xxxx", "xxx") or die('Couldn\'t connect to MySQL Server: ' . mysql_error()); mysql_select_db("xxxx", $connect ) or die('Couldn\'t Select the database: ' . mysql_error( $connect )); $links = Array(); $URL = 'http://www.theqlick.com'; // change it for urls to grab // grabs the urls from URL $file = file_get_html($URL); foreach ($file->find('a') as $theelement) { $links[] = url_to_absolute($URL, $theelement->href); } print_r($links); mysql_query("INSERT INTO pages (url) VALUES ('$links[]')"); mysql_close($connect);

    Read the article

  • PHP rewrite an included file - is this a valid script?

    - by Poni
    Hi all! I've made this question: http://stackoverflow.com/questions/2921469/php-mutual-exclusion-mutex As said there, I want several sources to send their stats once in a while, and these stats will be showed at the website's main page. My problem is that I want this to be done in an atomic manner, so no update of the stats will overlap another one running in the background. Now, I came up with this solution and I want you PHP experts to judge it. stats.php <?php define("my_counter", 12); ?> index.php <?php include "stats.php"; echo constant("my_counter"); ?> update.php <?php $old_error_reporting = error_reporting(0); include "stats.php"; define("my_stats_template",' <?php define("my_counter", %d); ?> '); $fd = fopen("stats.php", "w+"); if($fd) { if (flock($fd, LOCK_EX)) { $my_counter = 0; try { $my_counter = constant("my_counter"); } catch(Exception $e) { } $my_counter++; $new_stats = sprintf(constant("my_stats_template"), $my_counter); echo "Counter should stand at $my_counter"; fwrite($fd, $new_stats); } flock($fd, LOCK_UN); fclose($fd); } error_reporting($old_error_reporting); ?> Several clients will call the "update.php" file once every 60sec each. The "index.php" is going to use the "stats.php" file all the time as you can see. What's your opinion?

    Read the article

  • syntax for MySQL INSERT with an array of columns

    - by Mike_Laird
    I'm new to PHP and MySQL query construction. I have a processor for a large form. A few fields are required, most fields are user optional. In my case, the HTML ids and the MySQL column names are identical. I've found tutorials about using arrays to convert $_POST into the fields and values for INSERT INTO, but I can't get them working - after many hours. I've stepped back to make a very simple INSERT using arrays and variables, but I'm still stumped. The following line works and INSERTs 5 items into a database with over 100 columns. The first 4 items are strings, the 5th item, monthlyRental is an integer. $query = "INSERT INTO `$table` (country, stateProvince, city3, city3Geocode, monthlyRental) VALUES ( '$country', '$stateProvince', '$city3', '$city3Geocode', '$monthlyRental')"; When I make an array for the fields and use it, as follows: $colsx = array('country,', 'stateProvince,', 'city3,', 'city3Geocode,', 'monthlyRental'); $query = "INSERT INTO `$table` ('$colsx') VALUES ( '$country', '$stateProvince', '$city3', '$city3Geocode', '$monthlyRental')"; I get a MySQL error - check the manual that corresponds to your MySQL server version for the right syntax to use near ''Array') VALUES ( 'US', 'New York', 'Fairport, Monroe County, New York', '(43.09)' at line 1. I get this error whether the array items have commas inside the single quotes or not. I've done a lot of reading and tried many combinations and I can't get it. I want to see the proper syntax on a small scale before I go back to foreach expressions to process $_POST and both the fields and values are arrays. And yes, I know I should use mysql_real_escape_string, but that is an easy later step in the foreach. Lastly, some clues about the syntax for an array of values would be helpful, particularly if it is different from the fields array. I know I need to add a null as the first array item to trigger the MySQL autoincrement id. What else? I'm pretty new, so please be specific.

    Read the article

  • Can't call an object method. PHP reports variable undefined

    - by user1285697
    This is the weirdest bug! It is probably something silly, but I have no idea how to fix it. If anyone could help, I would be most grateful! I have three files, one is called items.php, another is called tableFunctions.php, and the third is called mysql.php. I use two global objects called 'mysql' and 'tableFunctions'. They are stored in the files 'mysql.php', and 'tableFunctions.php', respectively. In each file, I create an instance of its object, assigning it to the global variable $_mysql, or $_table. like this: In the file mysql.php: global $_mysql; $_mysql = new mysql(); In the file tableFunctions.php: global $_table; $_table = new tableFunctions(); Here's how it is supposed to work: The items.php file includes the tableFunctions.php file... Which in turn, needs the mysql.php file, so it includes it too. In the items.php file, I call the method getTable(), which is contained in the object tableFunctions.(and in the variable $_table.) Like this: $t = $_table->getTable('items'); The getTable function calls the method, arrayFromResult(), which is contained within in the object mysql.(and in the variable $_mysql.) Like this: $result = $_mysql->arrayFromResult($r); That's where I get the error. PHP says that the variable '$_mysql' is undefined, but I defined it in the 'mysql.php' file.(see above) I also included mysql.php with the following code: include_once 'mysql.php'; I have no idea what is wrong! If anyone can help that would be much appreciated. The source files can be downloaded with the following link: https://www.dropbox.com/sh/bjj2gyjsybym89r/YLxqyNvQdn

    Read the article

  • Help to Understand PHP Code into C#

    - by user342944
    Hi Gurus, I am a C# guy and got this logic into php from a website. Need to implement the same in C#. $items = array(); while($row = mysql_fetch_assoc($query)) { //parent id $pkey = $row['parent_id']; //child id $ckey = $row['category_id']; //store this $items[$pkey]['children'][$ckey] = $row['categoryname']; } //create our list $first = true; //create our list createList($items, $first); function createList($array, $first) { //we need access to the original array global $items; //first is a flag on whether or not this is the first item in the array //we use this flag so that you don't need to initially call the function using createList($array[0]['children']) if($first){ $array = $array[0]['children']; } echo "<ol>\n"; foreach($array as $key => $value){ echo "<li>{$value}"; //if this item does have children, display them if(isset($items[$key]['children'])){ echo "\n"; createList($items[$key]['children'], false); //set $first to false! } echo "</li>\n"; } echo "</ol>\n"; } In the above last line is it a 3 dimensional array or hashtable? it looks like its a hashtable cause [$pkey]['children'][$ckey] is bugging me.. Can anyone convert the above code in C#? I would really appreciate.

    Read the article

  • Why doesn't this require_once statement find the file? (PHP)

    - by ggfan
    I not sure what's going on..maybe I missed something simple. In my connectvars.php file, I connect to the database using the variables in my config.php folder. Here's the hierarchy: admin(folder) config.php includes(folder) connectvars.php I want to get information from config.php to use in connectvars.php, so I use: require_once("../admin/config.php"); But everytime I do this I get Warning: require_once(../admin/config.php) [function.require-once]: failed to open stream: No such file or directory in /home/a8879415/public_html/includes/connectvars.php on line 2 BUT when I type: require_once("admin/config.php");, it works. I thought I had to go up a level, then go down to admin, then get config.php. So how come I just need to go into the admin folder then get config.php?

    Read the article

  • php in_array() inside a foreach

    - by 432skronker
    I am having issues with using in_array() inside a foreach loop. Not sure if this is even possible or if I am doing something ridiculous where there are better ways. What I want to do is go through all the items and if their item id matches one thats in the array, return true and add the price of the item to a runninng total. $price = 0; $result = false; $array = array(1533, 2343, 2333); foreach($order['items'] as $item){ if(in_array($item['Item'], $array)){ $result = true; $price += $item['Price']; } } **UPDATED** Here is the order array [items] => Array ( [0] => Array ( [Item] => 139957 [OrderID] => 16025 [SizeID] => 24 [Price] => 46.00 ) [1] => Array ( [Item] => 2343 [OrderID] => 16025 [SizeID] => 12 [Price] => 32.00 ) ) [data] => Array ( )

    Read the article

  • PHP Array issue - not looping through foreach...

    - by Homer_J
    Ok, Here is the code: function fetch_questions($page) { global $link; $proc = mysqli_prepare($link, "SELECT * FROM tquestions_cwh WHERE page = ?"); mysqli_stmt_bind_param($proc, "i", $page); mysqli_stmt_execute($proc); $rows = array(); stmt_bind_assoc($proc, $rowq); // loop through all result rows while ($proc->fetch()) { // print_r($rowq); $rows[]=$rowq; } mysqli_stmt_close($proc); mysqli_clean_connection($link); return($rows); } I then add this to a php variable, like so: $qs = fetch_questions($page); I then loop through is, like so: foreach($qs as $value){ echo "<tr>".$value['qnum']." is the questions number and the question text is ".$value['qtext'].". The page and q values are ".$value['page']." and ".$value['questions']." respectively.</tr>"; The output, however is this: 8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively.8 is the questions number and the question text is I know how what I do fits into my team's objectives. The page and q values are 1 and q8 respectively. Which is not what I want, for information purposes, the array using the print function looks like this: Array ( [0] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [1] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [2] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [3] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [4] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [5] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [6] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) [7] => Array ( [questions] => q8 [qnum] => 8 [qtext] => I know how what I do fits into my team's objectives [page] => 1 ) ) Clearly it's not looping through and displaying each row as it should...any advice? Homer.

    Read the article

  • PHP+Apache as forward/reverse proxy: ¿how to process client requests and server responses in PHP?

    - by Lightworker
    Hi! I'm having a lot of troubles with the propper configuration of Apache mod_proxy.so to work as desired... The main idea, is to create a proxy on a local machine in a network wich will have the ability to proces a client request (client connected through this Apache prepared proxy) in PHP. And also, it will have the capacity to process the server responses on PHP too. Those are the 2 funcionalities, and they are independent one from each other. Let me present a little schema of what I need to achive: As you can see here, there're 2 ways: blue one and red one. For the blue one, I basically conected a client (Machine B - cell phone) on my local network (home) and configured it to go thorugh a proxy, wich is the Machine A (personal computer) on the exactly same network. So let's say (not DHCP): Machine A: 192.168.1.40 -- Apache is running on this machine, and configured to listen port 80. Machine B (cell phone): 192.168.1.75 -- configured to go throug a proxy, wich is IP 192.168.1.75 and port 80 (basically, Machine A). After configuring Apache properly, wich is basically to remove the "#" from httpd.conf on the lines for the mod_proxy.so (main worker), mod_proxy_connect.so (SSL, allowCONNECT, ...) and mod_proxy_http.so (needed for handle HTTP request/responses) and having in my case, lines like this: # Implements a proxy/gateway for Apache. Include "conf/extra/httpd-proxy.conf" # Various default settings Include "conf/extra/httpd-default.conf" # Secure (SSL/TLS) connections Include "conf/extra/httpd-ssl.conf" wich gives me the ability to configure the file httpd-proxy.conf to prepare the forward proxy or the reverse proxy. So I'm not sure, if what I need it's a forward proxy or a reverse one. For a forward proxy I've done this: <IfModule proxy_module> <IfModule proxy_http_module> # # FORWARD Proxy # #ProxyRequests Off ProxyRequests On ProxyVia On <Proxy *> Order deny,allow # Allow from all Deny from all Allow from 192.168.1 </Proxy> </IfModule> </IfModule> wich basically passes all the packets normally to the server and back to the client. I can trace it perfectly (and testing that works) looking at the "access.log" from Apache. Any request I make with the cell phone, appears then on the Apache log. So it works. But here come the problem: I need to process those client requests. And I need to do it, in PHP. I have read a lot about this. I've read in detail the oficial site from Apache about mod_proxy. And I've searched a lot on forums, but without luck. So I thought about a first aproximation: 1) Forward proxy in Apache, passes all the packets and it's not possible to process them. This seems to be true, so, what about a reverse proxy? So I envisioned something like: ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass http://www.google.com http://www.yahoo.com ProxyPassReverse http://www.google.com http://www.yahoo.com which is just a test, but this should cause on my cell phone that when trying to navigate to Google, I should be going to Yahoo, isn't it? But not. It doesn't work. So you really see, that ALL the examples on Apache reverse proxy, goes like: ProxyPass /foo http://foo.example.com/bar ProxyPassReverse /foo http://foo.example.com/bar wich means, that any kind of request in a local context, will be solved on a remote location. But what I needed is the inverse! It's that when asking for a remote site on my phone, I solve this request on my local server (the Apache one) to process it with a PHP module. So, if it's a forward proxy, I need to pass through PHP first. If it's a reverse proxy, I need to change the "going" direction to my local server one to process first on PHP. Then comes in mind second option: 2) I've seen something like: <Proxy http://example.com/foo/*> SetOutputFilter INCLUDES </Proxy> And I started to search for SetOutputFilter, SetInputFilter, AddOutputFilter and AddInputFilter. But I don't really know how can I use it. Seems to be good, or a solution to me, cause with somethin' like this, I should can add an Input filter to process on PHP the client requests and send back to the client what I programed/want (not the remote server response) wich is the BLUE path on schema, and I should have the ability to add an Output filter wich seems to give me the ability to process the remote server response befor sending it to the client, wich should be the RED path on the schema. Red path, it's just to read server responses and play with em. But nothing more. The Blue path, it's the important one. Cause I will send to the client whatever I want after procesing the requests. I so sorry for this amazingly big post, but I needed to explain it as well as I can. I hope someone will understand my problem, and will help me to solve it! Lot of thanks in advance!! :)

    Read the article

  • Looping class, for template engine kind of thing

    - by tarnfeld
    Hey, I am updating my class Nesty so it's infinite but I'm having a little trouble.... Here is the class: <?php Class Nesty { // Class Variables private $text; private $data = array(); private $loops = 0; private $maxLoops = 0; public function __construct($text,$data = array(),$maxLoops = 5) { // Set the class vars $this->text = $text; $this->data = $data; $this->maxLoops = $maxLoops; } // Loop funtion private function loopThrough($data) { if( ($this->loops +1) > $this->maxLoops ) { die("ERROR: Too many loops!"); } else { $keys = array_keys($data); for($x = 0; $x < count($keys); $x++) { if(is_array($data[$keys[$x]])) { $this->loopThrough($data[$keys[$x]]); } else { return $data[$keys[$x]]; } } } } // Templater method public function template() { echo $this->loopThrough($this->data); } } ?> Here is the code you would use to create an instance of the class: <?php // The nested array $data = array( "person" => array( "name" => "Tom Arnfeld", "age" => 15 ), "product" => array ( "name" => "Cakes", "price" => array ( "single" => 59, "double" => 99 ) ), "other" => "string" ); // Retreive the template text $file = "TestData.tpl"; $fp = fopen($file,"r"); $text = fread($fp,filesize($file)); // Create the Nesty object require_once('Nesty.php'); $nesty = new Nesty($text,$data); // Save the newly templated text to a variable $message $message = $nesty->template(); // Print out $message on the page echo("<pre>".$message."</pre>"); ?> Any ideas?

    Read the article

  • Problem making system calls with PHP scripts

    - by mazin k.
    I have the following PHP script: <?php $fortune = `fortune`; echo $fortune; ?> but the output is simply blank (no visible errors thrown). However, if I run php -a, it works: php > echo `fortune`; Be careful of reading health books, you might die of a misprint. -- Mark Twain php > Am I missing a config directive or something that would cause this? Edit: So, I tried running my script using $ php-cgi fortunetest.php and it worked as expected. Maybe the issue is with Apache2?

    Read the article

  • php doctrine last identifier issue

    - by mike
    I'm running in to the issue below when trying to run the following: $store = new Store(); $store->url =$this->form_validation->set_value('website'); $store->save(); $store_id = $store->identifier(); Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with message 'Couldn't get last insert identifier.' in /home/yummm/public_html/system/application/plugins/doctrine/lib/Doctrine/Connection/UnitOfWork.php:932 Stack trace: #0 /home/yummm/public_html/system/application/plugins/doctrine/lib/Doctrine/Connection/UnitOfWork.php(632): Doctrine_Connection_UnitOfWork->_assignIdentifier(Object(Category_store_assn)) #1 /home/yummm/public_html/system/application/plugins/doctrine/lib/Doctrine/Connection/UnitOfWork.php(562): Doctrine_Connection_UnitOfWork->processSingleInsert(Object(Category_store_assn)) #2 /home/yummm/public_html/system/application/plugins/doctrine/lib/Doctrine/Connection/UnitOfWork.php(81): Doctrine_Connection_UnitOfWork->insert(Object(Category_store_assn)) #3 /home/yummm/public_html/system/application/plugins/doctrine/lib/Doctrine/Record.php(1691): Doctrine_Connection_UnitOfWork->saveGraph(Object(Category_store_assn)) #4 /home/yummm/public_html/system/application/controllers/auth.php(375): Doctrine_Reco in /home/yummm/public_html/system/application/plugins/doctrine/lib/Doctrine/Connection/UnitOfWork.php on line 932 When I echo $store_id, it seems to be grabbing the last id without any issues. Any idea why this error keeps coming up even though the ID is passing correctly?

    Read the article

  • Error installing php extension OAuth via pecl

    - by hookedonwinter
    I'm trying to install the php extension OAuth in my local environment. php.net suggests it's super easy. You just run pecl install oauth. I tried this, and here is the output in terminal: downloading oauth-1.0.0.tgz ... Starting to download oauth-1.0.0.tgz (42,834 bytes) ............done: 42,834 bytes 6 source files, building running: phpize grep: /usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory Configuring for: PHP Api Version: Zend Module Api No: Zend Extension Api No: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. ERROR: `phpize' failed Any tips on how to fix the errors and install OAuth succesfully? Thanks!

    Read the article

  • Problem with running php script using mysql on tomcat

    - by Jack
    I am using tomcat 6 with JavaBridge. I have stored my php script in the following location. C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\project\test.php In test.php I am using curl and mysql. The php.ini in JavaBridge is stored in the following location C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\WEB-INF\cgi\php.ini and its contents are - extension_dir="C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\WEB-INF\cgi\x86-windows\ext" include_path="C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\WEB-INF\pear;." there is also a config file called mysql.ini whose contents are - extension = php_mysql.dll I had also installed wamp earlier so I copied all the dll's from C:\wamp\bin\php\php5.3.0\ext to C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\WEB-INF\cgi\x86-windows\ext When I start tomcat and run my script I get the following error - Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\project\test.php on line 534 Please help.

    Read the article

  • How to simplify this php switch statement?

    - by janoChen
    I would like to change this: // use appropiate lang.xx.php file according to the value of the $lang switch ($_SESSION['lang']) { case 'en': $lang_file = 'lang.en.php'; break; case 'es': $lang_file = 'lang.es.php'; break; case 'zh-tw': $lang_file = 'lang.zh-tw.php'; break; case 'zh-cn': $lang_file = 'lang.zh-cn.php'; break; default: $lang_file = 'lang.en.php'; } into something like this: //include file for final output include_once 'languages/lang.'.$_SESSION['lang'].'php; So that I can skip the whole switch part. I tried other combinations but they don't seem to work. Any suggestions?

    Read the article

< Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >