[PHP] Newbie needs help

2002-07-24 Thread ctan

Whats the difference between 'mysql_db_query' and 'mysql_query'?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Applying XSL to XML with PHP

2002-07-25 Thread ctan

I'm trying to apply XSL to XML stored in a MySQL database with PHP. How do I
go about doing this? I've tried following the example on php.net but I seem
to run into a lot of trouble. Here's how the code looks like (BTW aml is XML
stored in the argument Table):


if (! empty($searchword ))

   $query = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'";
   $result = mysql_query($query) or die ("Query failed");
   $line = mysql_fetch_array($result, MYSQL_ASSOC);

// Create an array
$arguments = array('/_xml'=> $line);

//XSL file
$xsl = "./sheet1.xsl"; 

// Create an XSLT processor
$xslthandler = xslt_create();

// Perform the transformation
$html = xslt_process( $xslthandler, 'arg:/_xml', $xsl, NULL, $arguments);

// Detect errors
if (!$html) die ('XSLT processing error: '.xslt_error($xslthandler));

// Destroy the XSLT processor
xslt_free($xslthandler);

// Output the resulting HTML
print $html;


What I get on the screen is:


Array ( [0] => "With the contents of my variable...")


And:


Warning: Sablotron error on line 1: XML parser error 2: syntax error in
/home/httpd/html/ctan/resultworkingcopy2.php on line 93 XSLT processing
error: XML parser error 2: syntax error


What gives? I really need to solve this urgent. Thanks...

Chia

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] RE: Applying XSL to XML with PHP

2002-07-25 Thread ctan

The XML would be something like this... 




  

  Argument from Position to Know
  
a is in a position to know whether A is true
a asserts that A is true
A is true
  
  Is a in a position to know whether A is true?
  Is a an honest (trustworthy, reliable) source?
  Did a actually assert that A is true?

  

 
  If any journalists learn about the invasion, then the newspapers
will print the news. And if the newspapers print the news, then the invasion
will not be a secret. If the invasion is not a secret, then our troops will
not have the advantage of surprise. If we do not have the advantage of
surprise, then the enemy will be prepared. And if the enemy is prepared,
then we are likely to suffer higher casualties. But no journalists learned
about the invasion. Therefore, we are not likely to suffer higher
casualties.
  
 


  we are likely to suffer higher
casualties


  

  we are not likely to suffer higher
casualties

  


  

  the enemy will be prepared


  

  our troops will not have the advantage
of surprise


  

  invasion is not a secret


  

  If any journalists learn about
the invasion


  

   no journalists learned
about the invasion

  

  
  

  the newspapers print the
news

  

  

  

  

  



Hope this helps...

chia

-Original Message-
From: Peter Clarke [mailto:[EMAIL PROTECTED]] 
Sent: 25 July 2002 13:06
To: Ctan
Cc: [EMAIL PROTECTED]
Subject: Re: Applying XSL to XML with PHP


Ctan wrote:
> I'm trying to apply XSL to XML stored in a MySQL database with PHP. 
> How do I go about doing this? I've tried following the example on 
> php.net but I seem to run into a lot of trouble. Here's how the code 
> looks like (BTW aml is XML stored in the argument Table):
> 
> 
> if (! empty($searchword ))
> 
>$query = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'";
>$result = mysql_query($query) or die ("Query failed");
>$line = mysql_fetch_array($result, MYSQL_ASSOC);
> 
> // Create an array
> $arguments = array('/_xml'=> $line);
> 
> //XSL file
> $xsl = "./sheet1.xsl";
> 
> // Create an XSLT processor
> $xslthandler = xslt_create();
> 
> // Perform the transformation
> $html = xslt_process( $xslthandler, 'arg:/_xml', $xsl, NULL, 
> $arguments);
> 
> // Detect errors
> if (!$html) die ('XSLT processing error: '.xslt_error($xslthandler));
> 
> // Destroy the XSLT processor
> xslt_free($xslthandler);
> 
> // Output the resulting HTML
> print $html;  
> 
> 
> What I get on the screen is:
> 
> 
> Array ( [0] => "With the contents of my variable...")
> 
> 
> And:
> 
> 
> Warning: Sablotron error on line 1: XML parser error 2: syntax error 
> in /home/httpd/html/ctan/resultworkingcopy2.php on line 93 XSLT 
> processing
> error: XML parser error 2: syntax error
> 
> 
> What gives? I really need to solve this urgent. Thanks...
> 
> Chia

What is the xml. There may be a content encoding problem or some other 
xml issue.

Peter



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] 'Previous' 1, 2, 3, 4, etc. 'Next'

2002-07-25 Thread ctan

I seem to have a problem getting the page to display beyond the limit if a
page, i.e. if the limit if 10 rows in a page I'll only get the 1st ten rows
and then a link to further rows but when I chick on them they give me
nothing. Here's the code:


$searchword = $_POST['searchword'];
print "Your word(s) is/are: $searchword\n\n";

// Searching by keyword
if (! empty($searchword )){ 
   $max = 0;
   $query = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'";
   $result1 = mysql_query($query)
or die ("Query failed");

// Determine the number of items containing the $searchword   
 while ($line1 = mysql_fetch_array($result1)){
 $max++;
 }  


// The number of results to be displayed on screen
$maxresult = 10; 

$sql_text = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'";

// When the current page is yet to be determined
if (!$page) { 
 $page = 1;
 } 

$backpage = $page - 1;
$nextpage = $page + 1;
$result2 = mysql_query($sql_text);
$start = ($maxresult * $page) - $maxresult; 
$num_rows = mysql_num_rows($result2); 

// When the query returns less or equal number of rows than the limit set by
$maxresult
if ($num_rows <= $maxresult) {
 $num_pages = 1; 
   } 

// When the query returns the exact limit set by $maxresult
else if (($num_rows % $maxresult) == 0) {
   $num_pages = ($num_rows / $maxresult);
   } 

// For any other cases...
else {
   $num_pages = ($num_rows / $maxresult) + 1;
   } 

// Declared as an integer
$num_pages = (int) $num_pages;

// The current page is greater than the total number of pages or 
// the current page is less than 0
if (($page > $num_pages) || ($page < 0)) {
 error("You have specified an invalid page number");
   }

// Set the limit per page   
$sql_text = $sql_text . " LIMIT $start, $maxresult";
$result2 = mysql_query($sql_text);

// The navigation between pages
// Ensure only display when total number of return results exceeds
$maxresult
// i.e. will not display if only 1 page
if ($max>$maxresult){
 print "- ";
   if ($backpage) { 
   print "Prev";
   } 

// If its the first page; have 'Prev' un-clickable
else {
   print "Prev";
   }

for ($i = 1; $i <= $num_pages; $i++) {
   if ($i != $page) { 

  print " $i ";
   } 
 else { 
  print " $i "; 
   } 
}

if ($page != $num_pages) {
   print "Next -";
   } 
else {
   print "Next -";
   }
   print "";
}

print "Results";
while ($line = mysql_fetch_array($result2, MYSQL_ASSOC)) {
print "\t\n";
// The different color, in this case light blue will
show that
//the particular table belong to search by
keywords
  foreach ($line as$col_value) {
print "\t\t$col_value\n";
  }
  print "\t\n";
}


}


I suspect the problem is because I set the limits to a page and thus
anything more is ignored. That particular area of code is highlighted in
red. Could anyone please tell me where I have gone wrong and how I can fix
this. Thank you loads in advance. Incidentally this will be use php script
to conduct search of a database, whereby the user inputs a 'searchword' to
look for in a HTML form and the php script which processes the form input. 

Chia



[PHP] Sablotron error

2002-08-01 Thread ctan

Hi...

I'm working on XML files where are stored in a MySQL database. With PHP I
intend to transform these XML with XSLT. After much difficulty, I managed to
sort out everything until the portion about xslt_process. The browser
returns:

Warning: Sablotron error on line 2: 'arg:/argument.dtd' not found in
/home/httpd/html/ctan/resultworkingcopy2.php on line 91
XSLT processing error: 'arg:/argument.dtd' not found

Anyone have any idea what's going on? I'd appreciate any help I can get on
this. Thanks in advance.

Chia

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] xslt_process

2002-07-22 Thread ctan

Hi all,

I'm trying to use xslt_process() to transform a variable containing XML data
with an xsl file into a result using PHP. Incidentally the XML is from an
external source, i.e. a database. However despite following the examples in
www.php.net I am unable to do so. The code works out to something like this:


if (! empty($searchword ))

   $query = "SELECT aml FROM arguments WHERE aml LIKE '%$searchword%'";
   $result = mysql_query($query) or die ("Query failed");
   $line = mysql_fetch_array($result, MYSQL_ASSOC);

var_dump($line);

// Create an array
$arguments = array('/_xml'=> $line);

//XSL file
$xsl = "./sheet1.xsl"; 

// Create an XSLT processor
$xslthandler = xslt_create();

// Perform the transformation
$html = xslt_process( $xslthandler, 'arg:/_xml', $xsl, NULL, $arguments);

// Detect errors
if (!$html) die ('XSLT processing error: '.xslt_error($xslthandler));

// Destroy the XSLT processor
xslt_free($xslthandler);

// Output the resulting HTML
print $html;


What I get on the screen is:


Array ( [0] => "With the contents of my variable...")


And:


Warning: Sablotron error on line 1: XML parser error 2: syntax error in
/home/httpd/html/ctan/resultworkingcopy2.php on line 93
XSLT processing error: XML parser error 2: syntax error


What gives? I'm really frustrated and would greatly appreciate it if someone
would point out where I've made an error before I start ripping all my hair
out! Thanks... Thanks... Thanks!

Regards,
Chia

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: xslt_process

2002-07-22 Thread ctan

Thanks for the quick response...

See the thing is the XML is stored in a MySQL database. Is that what you
mean Peter?

Chia

-Original Message-
From: Peter Clarke [mailto:[EMAIL PROTECTED]] 
Sent: 22 July 2002 13:56
To: [EMAIL PROTECTED]; Ctan
Cc: [EMAIL PROTECTED]
Subject: [PHP] Re: xslt_process




I may be missing something, but your not parsing XML. Your $line 
contains an array of data from the database, not xml.






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php