Jump to content

tunage

Members
  • Posts

    12
  • Joined

  • Last visited

tunage's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am trying to make a script that copies data from one table on one server to an identical table on another server. My issue is trying to inset the retrieved data via $insert_stmt->execute($row); If I load the data via fetch(), I get nothing, not even an error. If I use fetchAll(), I get an array to string conversion error: Notice: Array to string conversion in /usr/home/www/admin/tmpchkr2.php on line 107 $pdo = new PDO( 'mysql:host=' . DB_HOST_R2D2 . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); //yoda pdo settings $pdoyd = new PDO( 'mysql:host=' . DB_HOST_YODA . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); $pdoyd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdoyd->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); foreach($tblnames as $tbl){ $sql = 'truncate '.$tbl; $statementyd = $pdoyd->prepare($sql); $useryd = $statementyd->execute(); var_dump($statementyd); echo '<br>'; } foreach($tblnames as $tbl){ var_dump($tbl); if($tbl == 'cryptokeys'){ $insert_stmt = $pdoyd->prepare("INSERT INTO cryptokeys (id, domain_id, flags, active, content) VALUES (:id, :domain_id, :flags, :active, :content)"); $select_results = $pdo->prepare("SELECT * FROM cryptokeys"); $sresult = $select_results->execute(); //$sresult = $select_results->fetchAll(); while ($row = $select_results->fetchAll(PDO::FETCH_ASSOC)) { echo '<br>boo3'; $insert_stmt->execute($row); var_dump($insert_stmt); } } } How do I properly insert retrieved data from a select query of a different server table?
  2. I have data on a table1 on one server I need copied onto a table1 on another server that is freshly truncated. I am not getting any error output in the logs or on the screen, but no data ever appears on the second server. mysql replication is banned and no access to cli for mysqldump (this code will be hit numerous times during the day) $pdo = new PDO( 'mysql:host=' . DB_HOST_R2D2 . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); //yoda pdo settings $pdoyd = new PDO( 'mysql:host=' . DB_HOST_YODA . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); $pdoyd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdoyd->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //records table column names $recordstbl = array('id', 'name', 'type', 'content', 'ttl', 'prio', 'change_date', 'disabled', 'ordername', 'auth'); //domain table column names $domainstbl = array('id', 'name', 'master', 'last_check', 'type', 'notified_serial', 'account'); //crypto table column names $cryptotbl = array('id', 'domain_id', 'flags', 'active', 'content'); $tblnames = array('cryptokeys', 'domains', 'records'); //loop through yoda and trunacate all 3 tables foreach($tblnames as $tbl){ $sql = 'truncate '.$tbl; $statementyd = $pdoyd->prepare($sql); $useryd = $statementyd->execute(); var_dump($statementyd); echo '<br>'; } //crazy triple loop to get sql query correct foreach($tblnames as $tbl){ if($tblnames == 'cryptokeys'){ foreach($cryptotbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } if($tblnames == 'domains'){ foreach($domainstbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } if($tblnames == 'records'){ foreach($recordstbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } } logs (source) db1: mysql> select * from mysql.general_log; +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | event_time | user_host | thread_id | server_id | command_type | argument | +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name='nyctelecomm.com' and domain_id=6 | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='PRESIGNED' | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name='nyctelecomm.com' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='NSEC3PARAM' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select min(ordername) from records where ordername > '' and domain_id=6 and disabled=0 and ordername is not null | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select ordername, name from records where ordername <= '' and domain_id=6 and disabled=0 and ordername is not null order by 1 desc limit 1 | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='SOA-EDIT' | | 2016-01-17 00:34:11 | [powerdns] @ [108.61.175.20] | 420 | 1 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Prepare | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Execute | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Close stmt | | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Quit | | | 2016-01-17 00:34:13 | [powerdns] @ [108.61.175.20] | 421 | 1 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:13 | powerdns[powerdns] @ [108.61.175.20] | 421 | 1 | Quit | | | 2016-01-17 00:34:19 | root[root] @ localhost [] | 411 | 1 | Query | select * from mysql.general_log | +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ 17 rows in set (0.00 sec) logs (target) db2: mysql> select * from mysql.general_log; +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ | event_time | user_host | thread_id | server_id | command_type | argument | +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='www.zippy-mail.com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='zippy-mail.com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='' | | 2016-01-17 00:34:23 | powerdns[powerdns] @ localhost [127.0.0.1] | 8 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:25 | [powerdns] @ [108.61.175.20] | 246 | 2 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Prepare | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Execute | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Close stmt | | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Quit | | | 2016-01-17 00:34:26 | [powerdns] @ [108.61.175.20] | 247 | 2 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate cryptokeys | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate cryptokeys | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate domains | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate domains | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate records | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate records | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Quit | | | 2016-01-17 00:34:41 | root[root] @ localhost [] | 237 | 2 | Query | select id, domain_id, name, type, content from records | | 2016-01-17 00:34:49 | root[root] @ localhost [] | 237 | 2 | Query | select * from mysql.general_log | +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ 23 rows in set (0.00 sec)
  3. I have a RPC server class that accepts JSON data from an unspecified given 3rd party using cURL. I can see the data hit my class, I can store a var_dump into a for what appears to be the server request, but the output looks like receiving webserver info with references to the inbound object. But I do not see my JSON data 'foo:bar' <?php class jsonRPCServer { public static function handle($object) { if ( $_SERVER['REQUEST_METHOD'] != 'POST' || empty($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/json' ) { return false; } $request = json_decode(file_get_contents('php://input'),true); $args=func_get_args(); ob_start(); var_dump($_SERVER); $result2 = ob_get_clean(); $file = 'stripedump.txt'; $current = file_get_contents($file); $current .= $result2; file_put_contents($file, $current); try { if ($result = @call_user_func_array(array($object,$request['method']),$request['params'])) { $response = array ( 'id' => $request['id'], 'result' => $result, 'error' => NULL ); } else { $response = array ( 'id' => $request['id'], 'result' => NULL, 'error' => 'unknown method or incorrect parameters' ); } } catch (Exception $e) { $response = array ( 'id' => $request['id'], 'result' => NULL, 'error' => $e->getMessage() ); } if (!empty($request['id'])) { // notifications don't want response header('content-type: text/javascript'); echo json_encode($response); } return true; } } ?> <?php require_once 'example.php'; require_once 'jsonRPCServer.php'; $myExample = new example(); jsonRPCServer::handle($myExample) or print 'no request'; echo '<b>Attempt to perform basic operations</b><br />'."\n"; try { echo 'Your name is <i>'.$myExample->giveMeSomeData('name').'</i><br />'."\n"; $myExample->changeYourState('I am using this funnction from the local environement'); echo 'Your status request has been accepted<br />'."\n"; } catch (Exception $e) { echo nl2br($e->getMessage()).'<br />'."\n"; } var_dump($myExample); echo '<br /><b>Attempt to store strategic data</b><br />'."\n"; try { $myExample->writeSomething('bite me'); echo 'Strategic data succefully stored'; } catch (Exception $e) { echo nl2br($e->getMessage()); } ?> output from remote cURL client: gentoo-mini htdocs # curl -X POST -H "Content-Type: application/json" -d "{foo:bar}" http://nyctelecomm.com/hooker/ <b>Attempt to perform basic operations</b><br /> Your name is <i>Bubba</i><br /> Your status request has been accepted<br /> object(example)#1 (1) { ["someData":"example":private]=> array(2) { ["name"]=> string(5) "Bubba" ["attr"]=> string(17) "Some me Attribute" } } <br /><b>Attempt to store strategic data</b><br /> Strategic data succefully stored stored var_dump($_SERVER) data: array(29) { ["HTTP_HOST"]=> string(15) "nyccomm.com" ["HTTP_USER_AGENT"]=> string(11) "curl/7.42.1" ["HTTP_ACCEPT"]=> string(3) "*/*" ["CONTENT_TYPE"]=> string(16) "application/json" ["CONTENT_LENGTH"]=> string(1) "9" ["PATH"]=> string(29) "/sbin:/bin:/usr/sbin:/usr/bin" ["LD_LIBRARY_PATH"]=> string(29) "/usr/local/lib:/usr/local/lib" ["SERVER_SIGNATURE"]=> string(0) "" ["SERVER_SOFTWARE"]=> string(34) "Apache/2.4.12 (FreeBSD) PHP/5.6.10" ["SERVER_NAME"]=> string(15) "nyccomm.com" ["SERVER_ADDR"]=> string(13) "108.61.175.20" ["SERVER_PORT"]=> string(2) "80" ["REMOTE_ADDR"]=> string(12) "67.82.49.236" ["DOCUMENT_ROOT"]=> string(21) "/home/www" ["REQUEST_SCHEME"]=> string(4) "http" ["CONTEXT_PREFIX"]=> string(0) "" ["CONTEXT_DOCUMENT_ROOT"]=> string(21) "/home/www" ["SERVER_ADMIN"]=> string(19) "admin@ex-mailer.com" ["SCRIPT_FILENAME"]=> string(38) "/home/www/hooker/index.php" ["REMOTE_PORT"]=> string(5) "52841" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["SERVER_PROTOCOL"]=> string( "HTTP/1.1" ["REQUEST_METHOD"]=> string(4) "POST" ["QUERY_STRING"]=> string(0) "" ["REQUEST_URI"]=> string( "/hooker/" ["SCRIPT_NAME"]=> string(17) "/hooker/index.php" ["PHP_SELF"]=> string(17) "/hooker/index.php" ["REQUEST_TIME_FLOAT"]=> float(1436429001.683) ["REQUEST_TIME"]=> int(1436429001) } string(4) "name" tcpdump: 00:29:06.659025 IP 192.168.0.55.52841 > 108.61.175.20.vultr.com.http: Flags [P.], seq 1:148, ack 1, win 115, options [nop,nop,TS val 2017270703 ecr 2483478707], length 147 E....A@.@.f....7l=...i.P...g.I.]...s....... x=......POST /hooker/ HTTP/1.1 Host: nyctelecomm.com User-Agent: curl/7.42.1 Accept: */* Content-Type: application/json Content-Length: 9 {foo:bar} 00:29:06.746198 IP 108.61.175.20.vultr.com.http > 192.168.0.55.52841: Flags [P.], seq 1:561, ack 148, win 1033, options [nop,nop,TS val 2483478793 ecr 2017270703], length 560 E..dm.@.5...l=.....7.P.i.I.]....... :...... ... x=..HTTP/1.1 200 OK Date: Thu, 09 Jul 2015 08:03:21 GMT Server: Apache/2.4.12 (FreeBSD) PHP/5.6.10 X-Powered-By: PHP/5.6.10 Content-Length: 373 Content-Type: text/html; charset=UTF-8 <b>Attempt to perform basic operations</b><br /> Your name is <i>Bubba</i><br /> Your status request has been accepted<br /> object(example)#1 (1) { ["someData":"example":private]=> array(2) { ["name"]=> string(5) "Bubba" ["attr"]=> string(17) "Some me Attribute" } } <br /><b>Attempt to store strategic data</b><br /> Strategic data succefully stored 00:29:06.746271 IP 192.168.0.55.52841 > 108.61.175.20.vultr.com.http: Flags [.], ack 561, win 123, options [nop,nop,TS val 2017270790 ecr 2483478793], length 0 E..4.B@.@.gP...7l=...i.P.....I.....{.W..... How do I access the JSON data from my inbound RPC object? (specifically 'foo:bar')
  4. code and error update http://bpaste.net/show/200663/ Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in /var/www/localhost/htdocs/votebd/query2.php on line 15 array(0) { }
  5. what does 'select * from p_users;' say? Is there only one record in the db?
  6. I am trying to query tab delimited first and last names from a file against a table in mysql. I can see my data coming in from the file and test SQL works fine on the mysql command line, but I get zero results from my code. <?php require_once('auth.php'); $conn = new PDO("mysql:hostname=localhost;dbname=$dbname", $username, $pw); $file = fopen('nameList1.txt','r'); //change to whatever name it is $firstname = ''; $lastname = ''; $index = -1; $id = -1; $tab = ' '; //change this to the delimiter, of course while ($line = fgets($file)) { $index = strrpos($line, $tab); $firstname = substr($line, 0, $index); //var_dump($firstname); $lastname = substr($line, $index + strlen($tab)); //var_dump($lastname); $stmt = $conn->prepare("SELECT id FROM dbname WHERE FName = $firstname AND LName = $lastname"); $stmt->execute(); $result = $stmt->fetchAll(); var_dump($result); } fclose($file); ?> ****************************************************************** +-----------------------+--------------+------+-----+---------+----------------+ | id | mediumint(9) | NO | PRI | NULL | auto_increment | | StateVoterID | int(10) | YES | | NULL | | | CountyVoterID | int(10) | YES | | NULL | | | Title | char(30) | YES | | NULL | | | FName | char(30) | YES | | NULL | | | MName | char(30) | YES | | NULL | | | LName | char(30) | YES | | NULL | | | NameSuffix | char(30) | YES | | NULL | | | Birthdate | int(10) | YES | | NULL | | | Gender | char(30) | YES | | NULL | | | RegStNum | char(30) | YES | | NULL | | | RegStFrac | char(30) | YES | | NULL | | | RegStName | char(30) | YES | | NULL | | | RegStType | char(30) | YES | | NULL | | | RegUnitType | char(30) | YES | | NULL | | | RegStPreDirection | char(30) | YES | | NULL | | | RegStPostDirection | char(30) | YES | | NULL | | | RegUnitNum | int(10) | YES | | NULL | | | RegCity | char(30) | YES | | NULL | | | RegState | char(30) | YES | | NULL | | | RegZipCode | int(10) | YES | | NULL | | | CountyCode | int(10) | YES | | NULL | | | PrecinctCode | char(10) | YES | | NULL | | | PrecinctPart | char(30) | YES | | NULL | | | LegislativeDistrict | char(30) | YES | | NULL | | | CongressionalDistrict | char(30) | YES | | NULL | | | Mail1 | char(30) | YES | | NULL | | | Mail2 | char(30) | YES | | NULL | | | Mail3 | char(30) | YES | | NULL | | | Mail4 | char(30) | YES | | NULL | | | MailCity | char(30) | YES | | NULL | | | MailZip | char(30) | YES | | NULL | | | MailCountry | char(30) | YES | | NULL | | | Registrationdate | char(30) | YES | | NULL | | | AbsenteeType | char(30) | YES | | NULL | | | LastVoted | char(30) | YES | | NULL | | | StatusCode | char(30) | YES | | NULL | | +-----------------------+--------------+------+-----+---------+----------------+ 37 rows in set (0.00 sec) ********************************** test SQL *************************************************** mysql> SELECT * FROM list WHERE FName='TARA' AND LName='AABELLERA'; +----+--------------+---------------+-------+-------+-------+-----------+------------+-----------+--------+----------+-----------+-----------+-----------+-------------+-------------------+--------------------+------------+------------+----------+------------+------------+--------------+--------------+---------------------+-----------------------+-------+-------+-------+-------+----------+---------+-------------+------------------+--------------+------------+------------+ | id | StateVoterID | CountyVoterID | Title | FName | MName | LName | NameSuffix | Birthdate | Gender | RegStNum | RegStFrac | RegStName | RegStType | RegUnitType | RegStPreDirection | RegStPostDirection | RegUnitNum | RegCity | RegState | RegZipCode | CountyCode | PrecinctCode | PrecinctPart | LegislativeDistrict | CongressionalDistrict | Mail1 | Mail2 | Mail3 | Mail4 | MailCity | MailZip | MailCountry | Registrationdate | AbsenteeType | LastVoted | StatusCode | +----+--------------+---------------+-------+-------+-------+-----------+------------+-----------+--------+----------+-----------+-----------+-----------+-------------+-------------------+--------------------+------------+------------+----------+------------+------------+--------------+--------------+---------------------+-----------------------+-------+-------+-------+-------+----------+---------+-------------+------------------+--------------+------------+------------+ | 9 | 0 | 458198 | | TARA | L | AABELLERA | | 2 | F | 5804 | | 141ST | PL | | | NE | 0 | MARYSVILLE | WA | 98271 | 0 | 101231 | 0 | 39 | 2 | | | | | | | | 05/05/2004 | P | 11/08/2011 | A | +----+--------------+---------------+-------+-------+-------+-----------+------------+-----------+--------+----------+-----------+-----------+-----------+-------------+-------------------+--------------------+------------+------------+----------+------------+------------+--------------+--------------+---------------------+-----------------------+-------+-------+-------+-------+----------+---------+-------------+------------------+--------------+------------+------------+ 1 row in set (27.22 sec) *********************** var_dump() ************************************************* array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0) { } array(0)
  7. the id field has the value I need in $_SESSION['id'] which is gained via the -> $query = "SELECT * FROM customer"; (it is an auto increment distinct value). I need this value carried over to add-job.php from index.php via the $_SESSION['id'] variable. This is a dynamic value returned from the database query. mysql> SELECT * FROM customer -> ; +----+-----------+------------+------------+------------+ | id | cust_name | cust_addr | cust_phone | cust_email | +----+-----------+------------+------------+------------+ | 1 | bob | 666 bo rd | 2124442222 | bo@bo.com | | 2 | dude | 666 jo rd | 2124445555 | bub | | 3 | nnn | kju | 6666 | bo@bo2.com | | 4 | brad | 888 | 2124444444 | bo@jack.am | | 5 | brad2 | smirk | 2147483647 | go@jac.com | | 6 | another | 8888 bh rd | 2147483647 | knarly@me | | 7 | peach | 69 too | 2147483647 | iuhdihih | | 8 | peachy | 4442222 rd | 0 | do@do.com | +----+-----------+------------+------------+------------+ 8 rows in set (0.00 sec) mysql> desc customer; +------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | cust_name | varchar(100) | NO | | NULL | | | cust_addr | varchar(180) | NO | | NULL | | | cust_phone | int(11) | YES | | NULL | | | cust_email | varchar(90) | YES | | NULL | | +------------+--------------+------+-----+---------+----------------+ 5 rows in set (0.07 sec) Here is a visual I need this to go here and be reflected here via $_SESSION['id']
  8. also check your permissions. file close, write move etc... will bork if anything is not apache:apache or what ever your distro web server user/group is.
  9. the server address for starters. i.e. host='localhost'
  10. Why don't you just adjust the upload limit size in your php.ini?
  11. I am trying to do a select / save selection to $_SESSION['id'] / redirect but the only value I am able to pass to $_SESSION['id'] is the target url and not the selection. output -> http://i.imgur.com/QeGb89X.png ************************************ index.php ****************************************** <?php require_once("header.php");?> <!-- <form name="addjob" method="POST" action="" onsubmit="return getURL(add-job.php)> --> <form name="addjob" method="POST" action="" onsubmit="return getURL(add-job.php)"> <select name="bolredir"> <?php // selection box submit $query = "SELECT * FROM customer"; $result = $odb->query($query); $custkey; // var_dump($result); if($result->rowCount() > 0) { foreach($result as $item) { echo '<option value='.$item['id'].'>'; echo ($item['cust_name'] .",". $item['cust_addr'] .",". $item['cust_phone'] .",". $item['id']."<br />\n"); echo '</option>'; $_SESSION['id'] = $item['id']; } } // var_dump($_SESSION['cust_name']); ?> </select> <input type="submit" id="id" name="id" value="add-job.php"> </form> </body> ***************************************** header.php *********************************** darknet064tokyo contactdb # cat header.php <?php session_start(); if(isset($_POST['id'])){ //store as session variable $_SESSION['id'] = $_POST['id']; //forward browser header("Location: ".$_SESSION['id']); exit; } $host = "localhost"; $user = "custdb"; $pass = ""; $db = "accounting"; $odb = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass); ?>
×
×
  • 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.