PHP - Printing Simultaneously On Two Network Printers
Hello,
Greetings! I have php application for restaurant, basically there are two types of orders Kitchen Items and Bar items. A cashier enters a order from customers from computer A (say). We have two computers in kitchen, Computer B and in Bar, Computer C. When cashier from computer A clicks a button, depending upon the order type i need to print a chit on Computer B and/or Computer C. COmputer A, B, C are in same network. All computers have laser printer which can print any type of content. Well i tried to search the forum, i couldn't find anything that would be of my help. Can anyone tell me what would be the starting point for this?? Thanks watsmyname Similar TutorialsI have 64 rows of players and want each User to be able to choose to bookmark an player, as well as unbookmark it too. I have a bookmark table set up, and each time a User decides to bookmark(+) or unbookmark(-) an player a row is created in the data table. (Matching the player ID and User ID) That's working fine. A query reads the most recent row for each player to determine if there is a + or - button next to each player. Testing the query and adding some dummy data, that part of it works too. However, the issue is the initial state, which I want to be a +. Once I go live, the table will be empty, nothing for the query to return/produce. How do I create an initial state of a + with no rows and have it not used or swapped out when Users start clicking + or -?
$query = "SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1 "; $results = mysqli_query($con,$query); echo mysqli_error($con); while($row = mysqli_fetch_assoc($results)) { echo $row['bookmark']; if($row['bookmark'] == 0) { echo '-'; // this is where a form goes to remove a bookmark } else { echo '+'; // this is where a form goes to add a bookmark } } I tried to get it with CASE, but I don't think that's the right path. I also looked at UNION. I was able to get it to produce an initial state of +, but it still printed the already made up sample data too (so I have three instances of ++ or +-). (Players 2, 4 and 4)
Here is the what the UNION query looked like: $query = "(SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1) UNION (SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."' ORDER BY p.id desc LIMIT 1) ";
is it possible to have two open connections to two different mysql dbs at the same time? when i tried it, only the one on the bottom of the list was active. my config file looks like this: //---------------------------------------------// $dbname = 'xxx'; # Database Name $dbuser = 'xxx'; # Database Username $dbpass = 'xxx'; # Database Password $dbhost = 'xxx'; # Database Host $conn2 = mysql_connect($dbhost,$dbuser,$dbpass) or die ("Could not connect to $dbname: ".mysql_error()); mysql_select_db($dbname) or die ("Could not access the database: ".mysql_error()); $dbname5 = 'yyy'; # Database Name $dbuser5 = 'yyy'; # Database Username $dbpass5 = 'yyy'; # Database Password $dbhost5 = 'yyy'; # Database Host $conn = mysql_connect($dbhost5,$dbuser5,$dbpass5) or die ("Could not connect to $dbname5: ".mysql_error()); mysql_select_db($dbname5) or die ("Could not access the database: ".mysql_error()); //--------------------------------------// so i want to be able to do mysql_query($query,$conn2) when i need to access xxx db, but it doesn't seem to work that way. am i doing something incorrectly? any help would be greatly appreciated. I'm trying to create a simple search engine bot and have found the biggest issue is that of performance, it takes several hours to index all the links and ideally I need to run it once a day, the bottleneck occurs when pulling the data from the remote urls in terms of network transfer time. This could obviously be reduced massively if I could read from several url's simultaneously. Does anyone know how I could do this. I'm aware that in PHP5 there is thread functionality which may solve the problem but this is only available from the CLI. I heard that it could be done with CURL without having to go down the threaded route, does anyone know how nthis can be done or know of any examples on the net that I could look at? As a cheeky follow up, I was also thinking a potential problem could be the script getting out of hand and opening too many connections and I don't to cause a DOS attack! Is there a way that the number of connections could be limited to 10 for example. Is there a way of detecting when a CURL connection has finished reading a file so that a connection manager class could then start the next connection asap? Thanks for any helpn people, I've been looking for this stuff for days!! Ok so I have a form to submits to a .php file that creates an image. This works fine, but I also want the info from the form to be sent to MySQL database. The problem is that something in a script I "required" called core.inc.php is interfering and so no image is output. Here is core.inc.php: Code: [Select] <?php ob_start(); session_start(); $current_file = $_SERVER['SCRIPT_NAME']; if(isset($_SERVER['HTTP_REFERER'])&&!empty($_SERVER['HTTP_REFERER'])) { $http_referer = $_SERVER['HTTP_REFERER']; } function loggedin() { if(isset($_SESSION['user_id'])&&!empty($_SESSION['user_id'])) { return true; } else { return false; } } function getuserfield($field) { $query="SELECT `$field` FROM `Users` WHERE `id`='".$_SESSION['user_id']."'"; if($query_run=mysql_query($query)) { if($query_result = mysql_result($query_run, 0, $field)) { return $query_result; } } } ?> Here is the code for the image creating .php file: Code: [Select] <?php require 'connect.inc.php'; require 'core.inc.php'; $title = $_REQUEST['title'] ; $user_id = getuserfield('id'); $query = "INSERT INTO `---` VALUES ('".mysql_real_escape_string($title)."','".mysql_real_escape_string($user_id)."')"; $query_run = mysql_query($query); //There is some more code in here obviously, but it's irrelevant header('Content-type: image/png'); imagepng($image_f); imagedestroy($image_f) Can anybody give me some idea of what is conflicting or what I can do to fix it? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=322398.0 Hi all, I am trying to create a socket that can read from and write to a client. This is my first attempt at it and the code in question is based more or less on a python script a friend sent me as well as some php tutorials google supplied. The problem is (and this seems to be a reoccurring one) when I run it from the command line Code: [Select] php -q server.php nothing visibly happens. Can anyone see what the problem might be? Code: [Select] <?php $host = "localhost"; $port = 50007; set_time_limit(0); // no timeout $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // create $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // bind $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // listen echo "Waiting for connections...\n"; $contact = socket_accept($socket) or die("Could not accept incoming connection\n"); // accept $input = socket_read($contact, 1024) or die("Could not read input\n"); // read $input = trim($input); // clean $output = "Greetings, you have connected to a socket.\n"; socket_write($contact, $output, strlen ($output)) or die("Could not write output\n"); // return socket_close($contact); // close socket socket_close($socket); // close socket ?> Hi, I'm a bit of a newbie when it comes to PHP. I'm a thirs year music/music tech student and for my disseration I took a very ambitious task. I want to create a sort of social networking site for musicians. But I wanted to create it dynamically using PHP and MySQL. I want to basically allow users to register and sign up with their details basically. But the first problem I came across was actually making a custom registration page, I wanted things such as post codes (zip codes) so that I would then have a Google Maps overlay showing where users were. So that you could 'see' you local music 'scene'. So far I've been playing around with Joomla, Drupal and WordPress. I tried writing the PHP from scratch but after following various tutorials, but I had no luck what-so-ever with that approach. So I started using content management systems, which got me a lot closer, but I found I couldn't really edit custom registration pages etc. And the I would have no idea how to get the Google maps idea working. If anyone could nudge me in the right direction and give me a few tips and ideas as to how I'm most likely to achieve this then please reply, I would be highly grateful for you responses. Thanks, Ewan Valentine. I have a PHP app that I wrote that requires a new IP address each time that it is run. Currently I use Tor on my desktop and the Vidalia app to change the Tor identity each time I run the script but I want to automate this. Can anyone help with switching Tor identities with PHP? Essentially after my script runs I need to call a function that switches to a new Tor identity. I have the following code but it doesn't seem to work, and I am not sure why. I am running this from XAMPP on OSX, Tor is running locally (client not server)... in my Tor settings I have 127.0.0.1 and port 9051, set to "no password"... Code: [Select] <?php function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code='') { $fp = fsockopen($tor_ip, $control_port, $errno, $errstr, 30); if (!$fp) { return false; //can't connect to the control port } fputs($fp, "AUTHENTICATE $auth_code\r\n"); $response = fread($fp, 1024); list($code, $text) = explode(' ', $response, 2); if ($code != '250') { return false; //authentication failed } //send the request to for new identity fputs($fp, "signal NEWNYM\r\n"); $response = fread($fp, 1024); list($code, $text) = explode(' ', $response, 2); if ($code != '250') { return false; //signal failed } fclose($fp); return true; } tor_new_identity(); ?> This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=327407.0 Hi,
I'm not sure if this is possible, however I'm sure somebody will be able to point me in the right direction. Relativley new to php here.
I would like to write a small app that will change my IP/Subnet Mask/Gateway depending on a selection made from a dropdown list. I will have a tota; of 50 different IP settings & drop downs (each drop down will represent a different location)
I have yet to start writing the app, just on paper so far - can this be done?
I have seen examples of batch scripts like the one below that work, would I need to incorporate something like this into my php?
netsh int ipv4 set address name="Local Area Connection" source=static address=10.127.86.25 mask=255.255.255.240 gateway=10.127.86.30This is just a personal project, I'm trying to further my knowledge! Thanks J I require a page to be added to my website. This page will facilitate a refined search via Google, Bing and Yahoo search engine simultaneously , show the top 5 of each engine. Is this possible using php ? Thank's Is there a way to write a file to a directory on my network? I tried creating a shortcut called automated and pointed it to the network path. I also set up a virtual directory called automated in IIS and still could not make it work. I gave it read and write permissions. error Warning: fopen(C:\Inetpub\wwwroot\dompdf\automated\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69 Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 70 Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 71 code Code: [Select] require_once("dompdf/dompdf_config.inc.php"); $html = '<html><body>'. '<p>Put your html here, or generate it with your favourite '. 'templating system.</p>'. '</body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $pdfoutput = $dompdf->output(); $filename = "C:\\Inetpub\\wwwroot\\dompdf\\automated\\resource.pdf"; $fp = fopen($filename, "a"); fwrite($fp, $pdfoutput); fclose($fp); This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=318962.0 I'm writing a mini social network and I'm having trouble figuring out how to deal with privacy settings. I have established a range of privacy options (level 1-4): 1. Only Facebook friends can see profile (users connect via FB) 2. Only current classmates 3. Past + current classmates 4. All users in given group I am writing a function to return a list of available users based on a given parameter (eg. Find all classmates of a user). Obviously I have to respect users privacy settings, so I thought to query against all users with level 2 permissions, however I realise that I may miss out some classmates who are FB friends but have permission levels set to 1. Secondly, I'm looking to find out the relationship between two users (a function that I can plug in 2 user IDs and return their relationship...classmates, FB friends, past classmates, no relationship) which I can then use to determine whether a user has permission to view another users profile. I don't have much code as of yet, because I spent a long time exploring one avenue which I now realise to be the wrong one! Any suggestions/help would be greatly appreciated!
Hello all, <?php // Connect to Phpmyadmin database localhost. $hostname = "localhost";//"";127.0.0.1 $username = "root"; $password = "password";//"password"; $dbname = "test"; $conn = new mysqli($hostname, $username, $password, $dbname); if($conn -> connect_error) { die("Connection failed: " . $conn -> connect_error); } // USED to CHANGE the db. - (mysqli_select_db($con, "test") or die()); /* Check to make all fields entered -make sure submitted- #2*/ if(isset($_POST["register"])) { if(!$_POST["email"] | !$_POST["password"] | !$_POST["password2"]) { die("You did not fill in all the fields"); } /* do escape strings for SQL injection */ $emailsafe = mysqli_real_escape_string($conn, $_POST["email"]); $passsafe = mysqli_real_escape_string($conn, $_POST["password"]); $pass2safe = mysqli_real_escape_string($conn, $_POST["password2"]); /* Check and see if email EXISTS in db. */ /* Insert email in db if does not exist */ $sql = "SELECT email FROM users WHERE email = '$emailsafe'";//limit 1 $result = $conn->query($sql) or die("invalid email check " . mysqli_error($conn)); $numrows = mysqli_num_rows($result); if($numrows != 0) { die("Sorry the email " . $_POST["email"] . "is already in use"); } // check if passwords both match if($_POST["password"] != $_POST["password2"]) { die("Passwords did NOT match"); } // if passwords match encrypt $hashedpass = password_hash($passsafe, PASSWORD_DEFAULT); // With everything escaped and hashed INSERT into db. $sqlINSERT = "INSERT INTO users(email, password) " . "VALUES('" . $emailsafe ."','". $hashedpass ."')"; if($query = $conn->query($sqlINSERT)=== TRUE) { echo '<script type="text/javascript">alert("Successfully INSERTed");</script>'; } else { die("Unsuccessful"); } $conn->close(); ?>
I ran my php with ajax and it creates the file successfully so i know it runs. I wanted to setup PHP debugging with atom or visual studio but i have not been able to successfully do that... I tried with xdebug so i just use the network tab inchrome to find if errors exist. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=331047.0 My user needs me to update the database on their server from data contained in a text file but do not want me to upload the text file to the server but rather read the file from wherever it exists. Across the intranet. Uploading the file means that whomsoever needs to do this update requires write permission to a folder on the server & my user does not want that. Suggestions on how I should solve this problem would be greatly appreciated. BTW My code works fine if I upload the file and do the update in place on the server. Hi,
I'm newbie. My requirement is to open network shared folder from PHP.
This works fine in IE but not in Chrome.
Can anyone please help me ....
Thanks
I recently created an application and tested on my local production environment. the problem I'm having is a cookie gets set with an a session variable. It works on my dev environment and I am able to view it's contents. When I uploaded the files to Network Solutions I receive get this error: Warning: Invalid argument supplied for foreach() in /data/18/1/27/121/1842447/user/1999590/htdocs/includes/session.php on line 55 and when I dump the variable it is empty. The version of php I am using is 5.3 and the version php Network Solutions is using is 5.1. Do you think it could be something with the two different versions of php or could it be a setting on their end. I am a novice php developer and I would appreciate any input thanks. So I would like it as a custom script or as a wordpress plugin. The features a I would like to build a social network. The main to features I’m interested in: 1. Member can join only by invitation. The person that invites another person must write a review about the invited person, add a photo, what he does, share the name and contact: email, phone, city, connected to ( until here all these is mandatory in order for the person to join the network ) and website link ( optional ). Only then the person that is invited will receive an email with a link from where to register his account. ( this only for members that will have the right to invite others. For the other type only the admin has the right to make it from just a member, a member with invitation rights. In this case the member will receive an email with a link registration ). The review of a member can be edited only the member who introduced that person in the network ( and the admin ). In case of any edit there will be a notification for the admin with the original version and the new version. The admin of the site has to allow the modification in order for the review to change. 2. The person that is already in the network can invite a number of … ( this will be fixed and determined by the admin. However the admin can raise the number of invitation for a particular member at his will ). This applies for the 2 types of invitations. There will be 2 types of invitations: to join the network and have the right to invite others OR only member ( no right to invite others ). When a person registers to the network, the one who invited him will have one less invitation for the type of member he introduced ( member with invitation rights or member ). If a member wants to invite more people than his invitation are, then it can purchase invitations ( both types ) for different prices ( example: 1 invitations 10$, 2 invitations – 40$ - value determined by the admin ). So a payment integration is needed ( Paypal ). The exception for all this: if a visitor wants to join the network without any invitation he can only pay his way in. However this option will be displayed on the public pages. After payment confirmation the visitor can be redirected to the register page. Admin will make the account active. A sign “paying member” will be shown on this member profile page. After a member is registered and logs in to his account will have the right to: - Add more photos - Add more website links - Add more details at his contact information - Change his unique number. - Have the option to add members ( both types ) - Add updates to his wall. - Search and contact other members via email. So once you log in to the account there is no restriction ( within the network ) or no difference from what you can do on other social sites. Search: First the search will be done in the reviews and after that on the post that members made. The search results will be displayed in the same order ( the words from the reviews will have priority and after that will be displayed the content from posts – that will be arranged in chronologic order – last one will be the first ). But a member can filter those results – review only or posts only. Sponsored bids will be displayed first. The handshake section: Here you will be notified if one of your “looking for” or “offering” announces has expired. When expired the announcement can’t be find on searches or on your profile page. The notification will be active for 7 days. By active I mean: if you click the notification it will take you to the announcement and there you will have an option – make active ( so that other can find the announcement in their searches or in your profile ) another 30 days. The Admin section: The site will be default “no robots” ( not indexed by search engines ). However an option should be in the admin to switch from off “no robots”. This option will apply only for the internal part – profile pages. The pages and link on the first page ( what is public ) can be indexed by search engines. A simple editor from where you can create pages ( something like the section pages in Wordpress ). Any page you create will appear on the first page. After a period of time a member with invitation rights will receive invitation. Example: after one year you will have an extra one invitation for both types of member. What is needed in the admin: a section from where you can modify this time ( time should be in months and the admin will enter the number – example if he puts 1 – that means after 1 month will receive invitation. There should be 2 sections: one time for members that can invite, and one for members only ). A section where you can limit the number of entries for “looking for” and “offering” The section from where you can edit the html code. An option to send newsletters. You will receive and email if another person contacted you via internal email section. Option to delete members. |