Jump to content

deeem

Members
  • Posts

    11
  • Joined

  • Last visited

Contact Methods

  • MSN
    deeem119@hotmail.com
  • Website URL
    http://www.toxictomato.co.uk/

Profile Information

  • Gender
    Not Telling
  • Location
    UK - Southampton

deeem's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'd actually go for this (including the previous comment on semi-colons at the end of lines): <?php // I should think the following 4 lines correspond to the 4 fields indicated in the screenshot attached at the // end of this message $contactfield1=$_POST["contactfield1"]; // this is field 1 $contactfield2=$_POST["contactfield2"]; // this is field 2 $contactfield3=$_POST["contactfield3"]; // etc $contactfield4=$_POST["contactfield4"]; $email_from = ""; $subject = "" ; //$email_txt = ""; $email_to = "[b]my email id here[/b]"; $message = "field1: $contactfield1\n field2 :$contactfield2 \n field3 :$contactfield3 \n field4 : $contactfield4 \n "; mail($email_to, $subject, $message,$email_from); ?> I think the $_POST key names have to be left the same, as I dont see anywhere on the sceenshot to modify them. I'd guess the program uses generic key names for the form vars. Also, there's a chance the form uses GET instead of POST, so you might need to change the $_POST to $_GET for all those vars. Would check your site to find out, but I'm at work at the moment.
  2. Recently upgraded our PHP install from 5.2.0 to 5.2.8. Everything continued working without a hitch, except one script... The Wake-On-LAN one. This script was written by someone else (I have a feeling I originally got it off this forum) and barely changed for my use: function WakeOnLan($mac) { // Create Magic Packet for($i=0;$i<6;$i++) $packet .= chr(255); $mac_byte = explode(':', $mac); for($i=0;$i<6;$i++) $mac_addr .= chr(hexdec($mac_byte[$i])); for($i=0;$i<16;$i++) $packet .= $mac_addr; // Set to UDP broadcast $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE); socket_sendto($sock, $packet, strlen($packet), 0, '255.255.255.255', 9); socket_close($sock); return; } $mac = $_GET['pcid']; WakeOnLan($mac); It exits on the socket_create without generating an error, even with error_reporting set to E_ALL. Have checked the usage of socket_create on the PHP site, but all seems in order. This is PHP running under IIS6 on Win2003 as an ISAPI module. Can anyone offer any help?
  3. Fixed! $mysqli = new mysqli("localhost", "user", "password", "db"); $csvarray = array( "col1" => "i", "col2" => "i", "col3" => "s", "col4" => "i", "col5" => "s", "col6" => "s", "col7" => "s"); $csvvars = array(); $dtypes[0] = ""; $cols = ""; $values = ""; foreach ($csvarray as $key => $value) { array_push($csvvars, &$$key); $dtypes[0].= $value; if ($cols != "") { $cols.= ","; $values.= ","; } $cols.= $key; $values.= "?"; } $params = array_merge($dtypes, $csvvars); $insert_stmt = $mysqli->prepare("INSERT INTO m ($cols) VALUES ($values)"); call_user_func_array(array($insert_stmt, 'bind_param'), $params); for ($i=0;$i<10;$i++) { foreach ($csvarray as $key=>$value) { $$key = "whatever"; } $insert_stmt->execute(); } $insert_stmt->close(); $mysqli->close(); Passing the variable names by reference, and using the double-dollar ($$) approach to make them named variables from the contents of the array, has done the job. Much neater.
  4. OK, need a bit of help. I cant quite understand how this works, or if what I want to do is even possible. I'm reading in a CSV file with around 50 columns, and need to put each line in a DB. I want to use mysqli prepared statements since the data in the sheets could be anything, but columns are likely to be added / removed at short notice. Fighting my way through and keeping track of vars and data types the amount of times they'd have to be repeated if doing this the plain vanilla method doesn't appeal to me, so I'd like to find a more structured method. I've come up with the following code, which I'm fairly sure wont work - my understanding is getting quite hazy by the end, so I'm not sure how to finish it: (I've reduced the number of column names for convenience) $mysqli = new mysqli("localhost", "dbname", "uname", "password"); // table column names matched to datatypes for mysqli bind_params, over 50 entries in real script $csvarray = array( "col1" => "i", "col2" => "i", "col3" => "s", "col4" => "i", "col5" => "s", "col6" => "s"); $csvvars = array(); $dtypes[0] = ""; $cols = ""; $values = ""; foreach ($csvarray as $key => $value) { array_push($csvvars, $key); $dtypes[0].= $value; if ($cols != "") { $cols.= ","; $values.= ","; } $cols.= $key; $values.= "?"; } $csvvars = array_merge($dtypes, $csvvars); $insert_stmt = $mysqli->prepare("INSERT INTO testtable ($cols) VALUES ($values)"); call_user_func_array(array($insert_stmt, 'bind_param'), $csvvars); At this point I've been struggling with this for a while. Never used call_user_func_array before, but it appears to do something like what I'm looking for - loading the list of column names to be used in $cols as the fields to insert into in the mysql table, producing the string of ?s for $values and most importantly the parameters for bind_param. Can anyone see what I'm trying to do here, and can anyone tell me if I'm going in the right direction or need to abandon it and run screaming back to a vanilla list of variables.
  5. Yep, the logged in Windows user who is viewing the page.
  6. I sometimes create PHP intranet apps for use in a Windows/AD environment. Is there any way of finding out the logged in user ID so I dont need to ask people to type it in, and if so, can someone enlighten me? Thanks,
  7. When my pc is restarted, i can use localhost or 127.0.0.1 in explorer to view my own page on my own pc, but the page is not available from outside our LAN until i stop apache, exit the apache monitor, then restart the monitor and restart the apache service. Any clues? It has me completely baffled...
  8. Have you paid for a domain name? Don\'t think it\'s possible to get one for free... .com addys are normally hugely expensive compared to .info or .uk or whichever country you may be in. www.freeparking.co.uk is good for .co.uk addresses.
  9. Aha! Found the problem!! The \"ServerName\" entry in Apache\'s httpd.conf... All fixed, thanks for the help!
  10. I used to use port 8080 as my http port, with my router directing all port 80 queries there, but i recently changed to port 80. Now, whenever i access phpmyadmin on the web server, none of the links do anything, as they all seem to append :8080 to the hostname in the browser... Any ideas?
  11. Arg! I\'m trying to set up a wap page, simple for now. Just says hello. The page works off of localhost with WinWAP pc based wap browser, but whenever i try to access it from a phone, all i get is: Bad answer from origin server ...and it is starting to irritate me :evil: . I\'ve got the mimetypes set up, they obviously work to a certain extent as winWAP can see and read the page, but phones cant! Any help would be greatly appreciated! PS: I\'m using Apache ver 2.0.45 I have no idea whether this is an apache problem, but i thought it was a good place to start.
×
×
  • 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.