Jump to content

johnnc

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johnnc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks Tenyon, I appreciate it. What an easy oversight I made there. thanks again, J
  2. Greetings, I am trying to write XML using SimpleXML for a web service call. I was having success until the XML got a little more complicated. Here is the XML format where I am running into problems: <Agent> <Person Last='Smith' First='John'> <Addresses /> <PhoneNumbers> <Phone Type='1' Number='888-555-1212'> </PhoneNumbers> </Person> </Agent> Here is my php: $xmlOutput = new SimpleXMLElement('<?xml version="1.0"?><ReportRequest> </ReportRequest>'); $xmlOutput->addAttribute('CID','9200'); $xmlOutput->addAttribute('Diagram','1'); $xmlOutput->addAttribute('DueDate','2011-11-15'); $xmlOutput->addAttribute('NumPhotos','6'); $xmlOutput->addAttribute('InspectAfter',''); $xmlOutput->addAttribute('PolicyNumber','JTC0004425'); $reportType = $xmlOutput->addChild('ReportType'); $reportType->addAttribute('CPType','Commercial'); $reportType->addAttribute('SectionIDs',''); $reportType->addAttribute('Description',''); $reportType->addAttribute('ReportTypeID','123'); $locations = $xmlOutput->addChild('Locations')->addChild('Addresses')->addChild('Address'); $locations->addAttribute('Zip','91216'); $locations->addAttribute('City','Chatsworth'); $locations->addAttribute('Line1','123 Main St'); $locations->addAttribute('Line2','Suite 201'); $locations->addAttribute('State','CA'); $locations->addAttribute('Latitude',''); $locations->addAttribute('Longitude',''); $agent = $xmlOutput->addChild('Agent')->addChild('Person')->addChild('Addresses')->addChild('PhoneNumbers')->addChild('Phone'); $agent->addAttribute('Last','Smith'); $agent->addAttribute('Email',''); $agent->addAttribute('First','John'); $agent->addAttribute('Title',''); $agent->addAttribute('Type','1'); $agent->addAttribute('Number','888-555-1212'); $agent->addAttribute('TypeName','Office'); $agent->addAttribute('Extension',''); Header('Content-type: text/xml'); echo $xmlOutput->asXML(); Everything outputs as it should until the line that starts with $agent. I want the output to match the section above. I have tried several variations but I cannot seem to figure it out. I know the current PHP sample doesn't work. Help?? Thanks in advance, John
  3. MCHL, Yes, the sp returns 3 elements in a single row.
  4. They queries are working correctly but I added the code to be sure anyway. The first record returns the correct result but each subsequent record produces the following Warnings: Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in page.php on line 67 Warning: extract() [function.extract]: First argument should be an array in page.php on line 68 Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in page.php on line 100 Here is line 67 $row1 = mysqli_fetch_row($results1); Here is line 68 extract($row1); Here is line 100 mysqli_free_result($results1); These lines of code are for the stored procedure call and seem to be the problem. Any ideas? thanks again
  5. Line 103 is $row1 = mysqli_fetch_row($results1);
  6. Just to clarify, the above code works for the first record in the set but fails for all others. Here are the Warnings I am getting on record 2- end of resultset. Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in page.php on line 65 Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, null given in page.php on line 66 Warning: extract() [function.extract]: First argument should be an array in page.php on line 67 Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in page.php on line 74
  7. Here is the code... $starttime = date('h:i:s A'); $sqlid = 150000; $connect = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); /* $connect1 = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); $connect2 = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); */ $query = "SELECT * from table where id > " . $sqlid; $results = mysqli_query($connect,$query) or die(mysqli_error($connect)); if (mysqli_num_rows($results) != 0) { //Set counter variable to see how many records were processed $i=0; //Start the loop of retrieving the leads to be rated while ($row = mysqli_fetch_array($results, MYSQL_ASSOC)) { //Get the Age Factor and set the variable $query1 = "CALL sp_get_rates(" . $row["sqft"] ."," . $row["zip"] . "," . $row["yearbuilt"] . ")"; $results1 = mysqli_query($connect,$query1); $row1 = mysqli_fetch_row($results1); extract($row1); $cov = $row1[0]; $premYes = $row1[1]; $premNo = $row1[2]; //Update record with new information $query2 = "update tableset fireprem = " . $premYes . ", nonfireprem = " . $premNo . ", covfactor = ". $cov . " where id = " . $row["id"]; $results2 = mysqli_query($connect,$query2); //increment counter variable $i++; //Free sql resources mysqli_free_result($results1); } //Determine how many records received a rate $query3 = "select count(*) as count from aptmailinglist where id > " . $sqlid . " and fireprem <> '0.00'"; $results3 = mysqli_query($connect,$query3); $row3 = mysqli_fetch_row($results3); extract($row3); $endtime = date('h:i:s A'); //Print on screen the number of records that were processed echo "There were " . $i . " records processed<br>"; echo "There were " . $row3[0] . " records rated<br>"; //echo $i - $row3[0] . " records did not receive a rate<br>"; echo "Start Time = " . $starttime . "<br>"; echo "End Time = " . $endtime . "<br>"; //Close connections mysqli_free_result($results); //mysqli_free_result($results3); mysqli_close($connect); //mysqli_close($connect1); //mysqli_close($connect2); }
  8. Greetings, I am writing a batch program that executes 3 queries on a single page. Using mysql libraries and regular queries works just fine. I am rewriting the page to include a stored procedure. The first query gets several thousand rows from a table, the second query calls a stored procedure which returns a resultset and the third query updates the table with the results from the stored procedure. Queries 2 & 3 are inside a while loop and execute once for every record from query 1. Here is my connection string to the database: $connect = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); Query 1 = $results = mysqli_query($connect,$query) Query 2 = $results1 = mysqli_query($connect,$query1); Query 3 = $results2 = mysqli_query($connect,$query2); $query = Select * from table $query1 = Call stored Procedure $query2 = Update table set ... The above fails with this error message: Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in pagename on line 103 If I create 3 connection variables everything works as expected. $connect = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); $connect1 = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); $connect2 = mysqli_connect("localhost", "username", "password","database") or die ("The database is unavailable. Please try again later."); Is there a way to accomplish what I am trying to do without creating 3 identical connections to the database? I am a noob to this so go easy on my coding practices. This code actually processes 40+ records per second on an old Dell laptop thanks in advance
  9. That did it. Thank you very much, I really appreciate it.
  10. Thanks corbin, I will check the php.ini file. Here are the 2 Listen entries Listen localhost:80 Listen 192.168.1.68:80
  11. I restarted my laptop with the network cable unplugged. Apache runs as a service and starts automatically on startup. The service did not start. I looked at the error log and there isn't an entry. I then tried to start the process manually. When that failed I looked at the error log again, and still, no entry. I plugged the network cable in and hit Start and the service started immediately. Here is the resulting entries in my error log: PHP Warning: Module 'mysql' already loaded in Unknown on line 0 [Mon Mar 16 13:35:47 2009] [notice] Child 6004: Child process is running [Mon Mar 16 13:35:47 2009] [notice] Child 6004: Acquired the start mutex. [Mon Mar 16 13:35:47 2009] [notice] Child 6004: Starting 64 worker threads. [Mon Mar 16 13:35:47 2009] [notice] Child 6004: Starting thread to listen on port 80. [Mon Mar 16 13:35:47 2009] [notice] Child 6004: Starting thread to listen on port 80.
  12. Thanks Wildteen, problem #2 has been solved. I will post the error log when I restart the computer disconnected from my network.
  13. Hi All, I am fairly new to Apache. I have it installed and currently running on my Vista Ultimate Laptop. When I am connected to my home network, the Apache service starts and everything works just fine. If I take my laptop to another location, the Apache service will not start. The second issue I have is regarding the way I access my Apache server via the laptop. Since installation and configuration I have been able to hit my server using http://localhost/site. I haven't made any changes and I can no longer hit localhost. I have to specifically call the IP address of the laptop. I appreciate any help with these two issues. thanks in advance, John
×
×
  • 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.