nonshatter 26 Posting Whiz

Hey bud, Well from printing out the entire contents of the html array, you can see that the Release date is the 3rd row down.

$i=0;
	$x=0;
	while(isset($html[$i]))
	{
			echo $html[$i];
		$i++;
	}
Director: Gary Winick
Writers: Jose Rivera, Tim Sullivan
[B]Release Date: 9 June 2010 (UK) [/B]
Taglines: What if you had a second chance to find true love? See more » ..................
..................

This means that the line you want is located in array position 2. As the array starts from 0 and counts up. So it would be:

$html[0] = Director: Gary Winick
$html[1] = Writers: Jose Rivera, Tim Sullivan
$html[2] = Release Date: 9 June 2010 (UK)
$html[3] = Taglines: What if you had a second chance to find true love? See more

So the easy solution would be to simply echo out position 2.

echo $html[2];

However, if the Release date from a different imdb page was put into a different array position, this wouldn't work. So the most precise and dynamic way of doing this would be to create a regular expression to check what each array value contains before deciding whether or not to print it out. (This is something I've just started to learn as well, so it's probably not the most efficient way of doing it, but hey - if it ain't broke don't fix it!)

<?php
 // produce the release date of film
 
$some_link = 'http://www.imdb.com/title/tt0892318/';

$tagName = 'div';
$attrName = 'class';
$attrValue = 'txt-block';
$subtag = 'h4'; …
nonshatter 26 Posting Whiz

http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php Perhaps you should read this tutorial or something. You need to show some more effort before we can help!

nonshatter 26 Posting Whiz

Hey yea, that's no problem. Just start a new thread when you want to get started. Nonshatter

nonshatter 26 Posting Whiz

And yea, it would be best to call it as a function. Although it might be a bit tricky as each page may have different tags to display the same information, particularly with imdb as it's so rich of information.

I've only used this technique manually - plugging in the tag names and attributes as and when I need them. Let me know if you find a solution to this. Cheers

nonshatter 26 Posting Whiz

Yes you're correct. I'm not sure how to return just the one element, other than to only echo out the first value of the $html array E.g. $html[0];

This works:

<?php 

$some_link = 'http://www.imdb.com/title/tt1055292/';
$tagName = 'div';
$attrName = 'class';
$attrValue = 'txt-block';
$subtag = 'a';
 
$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
@$dom->loadHTMLFile($some_link);
 
$html = getTags($dom, $tagName, $attrName, $attrValue, $subtag);
 
	
		echo $html[0];
	
 
function getTags($dom, $tagName, $attrName, $attrValue, $subtag)
{
    	$html = '';
    	$domxpath = new DOMXPath($dom);
    	$newDom = new DOMDocument;
    	$newDom->formatOutput = true;
 
	//$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']");
 	$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']/$subtag");
    	$i = 0;
   	$x = 0;
    	while( $myItem = $filtered->item($i++) )
	{		
		$html[$x] = $filtered->item($x)->nodeValue ."<br>";
    		$x++;
	}
    	return $html;
 
}
?>
nonshatter 26 Posting Whiz

Yes, that should work just fine. Just remember to remove the "/$subtag" part of the domxpath query if you're only using three nodes:

$domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']/$subtag"); //remove "/$subtag"

Or failing that, you could keep the $subtag and try:
$tagName = 'div';
$attrName = 'class';
$attrValue = 'txt-block';
$subtag = 'a'

Make sense?

nonshatter 26 Posting Whiz

I'm getting good at solving my own problems moments after I post them

<table>
<?php 
	$i=0;
	while(isset($html[$i]))
	{
		if(strlen($html[$i] == 0))
		{
			$i++;
		}
?>
		<tr>
			<td><?php echo $html[$i]; ?></td>
		</tr>
<?php			
		$i++;
	}
?>
</table>
nonshatter 26 Posting Whiz

Hmm, yeah that's a bit strange. Personally, I don't trust these IDE environments like Dreamweaver. They can often be more trouble than they're worth!

To interpret the source code, I just navigated to that page (http://www.imdb.com/title/tt0892318/) in mozilla firefox, then right-click and select 'View-Source'. Then I Ctrl+F to search the source code for the interesting bit (the rating).

The rating as I see it on this page is held in the html:

<span style="display:none" id="star-bar-user-rate"><b>6.3</b><span class="mellow">/10</span></span>

Hope this helps! :)

nonshatter 26 Posting Whiz

Hi all, I have a fairly simple problem. I have an array which prints out the following text:

1
 
Full, Gen. 3
 
TMSWK2D
9
Poor write quality
2
 
Full, Gen. 1
 
TMSWK2C
 
Read Only, Clean Tape

The problem is after some of the lines of text, there are empty values, causing there to be a line break. Here is the code that prints out the values.

<table>
<?php 
	$i=0;
	while(isset($html[$i]))
	{
?>
		<tr>
			<td><?php echo $html[$i]; ?></td>
		</tr>
<?php			
		$i++;
	}
?>
</table>

I have tried these two solutions in the hope that if one evaluates to true, then the $i++ would effectively skip the blank value and continue to print the next array value, but this hasn't worked.

if($html[$i] == " ")
		{
			$i++;
		}
	
		if(empty($html[$i]))
		{
			$i++;
		}

Any help please?!

nonshatter 26 Posting Whiz

No, I meant what imdb url you were trying to get the starbar-meta class from. In this page I am testing from, the rating is in a span tag as follows:

<span style="display:none" id="star-bar-user-rate"><b>4.9</b>

Here is the same code I posted before, and it works!

<?php
$some_link = 'http://www.imdb.com/title/tt1055292/';
$tagName = 'span';
$attrName = 'id';
$attrValue = 'star-bar-user-rate';
$subtag = 'b';

$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
@$dom->loadHTMLFile($some_link);

$html = getTags($dom, $tagName, $attrName, $attrValue);

	$i=0;
	while(isset($html[$i]))
	{
		echo $html[$i];

		
		$i++;
	}

function getTags($dom, $tagName, $attrName, $attrValue)
{
    	$html = '';
    	$domxpath = new DOMXPath($dom);
    	$newDom = new DOMDocument;
    	$newDom->formatOutput = true;
	
	$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']");
		
    	$i = 0;
   	$x = 0;
    	while( $myItem = $filtered->item($i++) )
	{		
		$html[$x] = $filtered->item($x)->nodeValue ."<br>";
    		$x++;
	}
    	return $html;
	
}
?>
nonshatter 26 Posting Whiz

Hmm... It should work. Can you send me the URL you are trying to get that data from and I will have a look

nonshatter 26 Posting Whiz

Great! I'm glad it's working. Now I'm not 100% as I haven't had a chance to play around, but try something like this: (I got this from Here)

$tagName = 'div';
$attrName = 'class';
$attrValue = 'starbar-meta';
$subtag = 'b';                   // add the new subtag <b>

$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
@$dom->loadHTMLFile($some_link);

$html = getTags($dom, $tagName, $attrName, $attrValue, $subtag);      //call the function with the new subtag

	$i=0;
	$x=0;
	while(isset($html[$i]))
	{
		echo $html[$i];		
                                  //remove the preg_split function if you don't need it
		$i++;
	}

function getTags($dom, $tagName, $attrName, $attrValue, $subtag)      //pass the subtag parameter
{
    	$html = '';
    	$domxpath = new DOMXPath($dom);
    	$newDom = new DOMDocument;
    	$newDom->formatOutput = true;
	
	$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']/$subtag");     //the new query should select all <b> tags within the node tree div -> class -> starbar-meta -> b
		
    	$i = 0;
   	$x = 0;
    	while( $myItem = $filtered->item($i++) )
	{		
		$html[$x] = $filtered->item($x)->nodeValue ."<br>";
    		$x++;
	}
    	return $html;
	
}
nonshatter 26 Posting Whiz

Hey David, you were right the code I posted just returned an empty array. No problem though, I just tested this code and it works on my set up.

<?php

$some_link = 'http://www.imdb.com/title/tt1055292/';
$tagName = 'h1';
$attrName = 'class';
$attrValue = 'header';

$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
@$dom->loadHTMLFile($some_link);

$html = getTags($dom, $tagName, $attrName, $attrValue);

	$i=0;
	while(isset($html[$i]))
	{
		echo $html[$i];

		$take = preg_split("/\ /", $html[$i]);

		for($n=0;$n<count($take);$n++)
		{ 
			print($take[$n]);
			echo "<br/>";
		}		
		$i++;
	}

function getTags($dom, $tagName, $attrName, $attrValue)
{
    	$html = '';
    	$domxpath = new DOMXPath($dom);
    	$newDom = new DOMDocument;
    	$newDom->formatOutput = true;
	
	$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']");
		
    	$i = 0;
   	$x = 0;
    	while( $myItem = $filtered->item($i++) )
	{		
		$html[$x] = $filtered->item($x)->nodeValue ."<br>";
    		$x++;
	}
    	return $html;
	
}
?>

This returns:

Life as We Know It (2010) 
Life
as
We
Know
It (2010)

I used the preg_split function to chop up the array value. This is useful if you are returning rows of a table, <tr>'s for example. I hope this helps and let me know how it goes!

nonshatter 26 Posting Whiz

Well a good start would be to post on a Java forum! Good luck x

nonshatter 26 Posting Whiz

Hi there, I have been doing something similar recently to obtain data contained in an external webpage. I have used the DOMDocument technique to achieve this. Take a look:

<?php
$some_link = 'www.imdb.com/webpage.html';
$tagName = 'div';
$attrName = 'id';
$attrValue = 'tn15title';

$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
@$dom->loadHTMLFile($some_link);

$html = getTags($dom, $tagName, $attrName, $attrValue);
echo $html;

function getTags($dom, $tagName, $attrName, $attrValue)
{
    	$html = '';
    	$domxpath = new DOMXPath($dom);
    	$newDom = new DOMDocument;
    	$newDom->formatOutput = true;
	
	$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']");
		
    	$i = 0;
   	$x = 0;
    	while( $myItem = $filtered->item($i++) )
	{		
		$html[$x] = $filtered->item($x)->nodeValue ."<br>";
    		$x++;
	}
    	return $html;
	
}
?>

You could adopt this for your needs... Here is the man page for it:
http://www.php.net/manual/en/book.dom.php

nonshatter 26 Posting Whiz

Hey Richieking! Thankyou for your help. Your code would work a charm if the content of my $html array was as simple as it looked! In fact, the reason why I was getting so many line breaks was because the values of the $html array had un-consistent spacing. (I used the DOMDocument method to formulate the array). When I did a view source on the retrieved data, I got something like:

1           Â Full, Gen. 3          Â          TMSWK2D    9            Â  Poor write quality

So some parts of the value had 11 spaces, and others had just one. Therefore it is completely impractical to try and code around this. Instead, I will go back to the DOMDocument and see if there is a way of returning more consistent data.

Anyhow, how can I get rid of/convert the "Â" character when printing out the row? I tried htmlentities() but that didn't seem to work.
chrz

nonshatter 26 Posting Whiz

OKay, I've attempted to use the explode() function, but am not getting correct results.

$i=0;
	$x=0;
	while(isset($html[$i]))
	{
		echo "<table>";
		echo "<tr><td>". $html[$i] ."</td></tr>";
		echo "</table>";

		$newArr = explode(" ", $html[$i]);    //use space as the delimeter
		while(isset($newArr[$x]))
		{
			echo $newArr[$x] ."<br>";
			$x++;
		}	
		$i++;
	}

I would expect to see:

1 
Full, 
Gen.
3  
TMSWK2D 
9 
Poor write quality

But instead, I get:

1 Â Full, Gen. 3 Â  TMSWK2D 9 Â  Poor write quality 
1







 Full,
Gen.
3







 






TMSWK2D



9











 
Poor
write
quality

With lots of line breaks in between each $newArr value... It's good but it's not right! Can anyone lend me some help!?

nonshatter 26 Posting Whiz

Hi all,
I have an array called html which contains rows of text.
E.g:

$html[0] = 1 Full, Gen. 3 TMSWK2D 9 Poor write quality 
$html[1] = 2 Full, Gen. 1 TMSWK2C  Read Only, Clean Tape

How would I go about taking each array value and splitting the row of text into individual values?
E.g:

$newArr[0][1] = 1
$newArr[1][1] = Full
$newArr[2][1] = Gen.
$newArr[3][1] = 3
$newArr[4][1] = TMSWK2D
$newArr[5][1] = 9
$newArr[6][1] = Poor write quality

$newArr[0][2] = 2
$newArr[1][2] = Full
$newArr[2][2] = Gen.
$newArr[3][2] = 1
$newArr[4][2] = TMSWK2C
$newArr[5][2] = 9
$newArr[6][2] = Read Only, Clean Tape
nonshatter 26 Posting Whiz

1) I do NOT want to put this piece of code into a PHP-file, as I want to use php INSIDE html to mask a hard-written e-mail address to prevent spam-robots finding it. (other solutions for that are welcome also)

All PHP code must be saved within a file with a .php extension otherwise it will not be interpreted! Regardless of where it is located (e.g. nested in html). You could encrypt the email address that is hard coded, or grab the email address dynamically. There are plenty of options for this!


2) All options given are already tested and not-working on the Apache-server of MY hosting-provider.
It IS working on anoter Apache-server at another hosting-provider!
So it must be something malfunctioning on the Apache-server at my hosting-provider.
I hope someone has knowledge of that kind of settings.

If you send us some more examples of the code that is/isn't working, we can try and give you more specific help!

nonshatter 26 Posting Whiz

First, make sure that the file is saved with a .php extension. Then try this:

<?php echo date("I F d, Y"); ?>

It could be that the uppercase "D"ate is causing the issue. Also, you are using short tags <? ?>. Some server configurations do not allow this. Instead, always use the full tags <?php ?>

nonshatter 26 Posting Whiz

Howdy,

I have a basic html file containing certain data I need to extract. This is the code for just one of the tables on the page:

<TABLE title="Left Magazine"class="dataTable" align="center" cellspacing="0" cellpadding="0">      <caption>Media Details</caption><THEAD><TR class="captionRow"><TH>Slot #</TH><TH>Attn</TH><TH>Status</TH><TH>In Drive</TH><TH>Label</TH><TH>Media Loads</TH><TH>Comment</TH></TR></THEAD>      <TBODY>
<TR class="altRowColor" >            <TD>1 </TD>          <TD>&nbsp;</TD><TD>Full, Gen. 3 </TD>         <TD>&nbsp;</TD>         <TD>TMSWK2D</TD><TD>    9</TD>            <TD>&nbsp; Poor write quality</TD>        </TR>
<TR class="altRowColor" >            <TD>2 </TD>          <TD>&nbsp;</TD><TD>Full, Gen. 1 </TD>         <TD>&nbsp;</TD>         <TD>TMSWK2C</TD><TD>&nbsp;</TD>           <TD>Read Only, Clean Tape</TD>        </TR>
<TR class="altRowColor" >            <TD>3 </TD>          <TD>&nbsp;</TD><TD>Full, Gen. 3 </TD>         <TD>&nbsp;</TD>         <TD>TMSWK2B</TD><TD>    9</TD>            <TD>&nbsp; Poor write quality</TD>        </TR>
<TR class="altRowColor" >            <TD>4 </TD>          <TD>&nbsp;</TD><TD>Full, Gen. 3 </TD>         <TD>&nbsp;</TD>         <TD>TMSWK2A</TD><TD>   10</TD>            <TD>&nbsp; Poor write quality</TD>        </TR>      </TBODY>      </TABLE>

auto.png


I need to extract the data from both of the "media information" tables, excluding the "in-drive" field. I have found some example code using the DOMDocument() function. This kind of works, but it selects every table in the page, rather than just the two tables + fields I need:

<?php	
    /*** a new dom object ***/ 
    $dom = new domDocument; 

    /*** load the html into the object ***/ 
    $dom->loadHTMLFile('inventory_status.html'); 

    /*** discard white space ***/ 
    $dom->preserveWhiteSpace = false; 

    /*** the table by its tag name ***/ 
    $tables = $dom->getElementsByTagName('table'); 

    /*** get all rows from the table ***/ 
    $rows = $tables->item(0)->getElementsByTagName('tr'); 
    
    /*** loop over the table rows ***/ 
    foreach ($rows as $row) 
    { 
        /*** get each column by tag name ***/ 
        $cols = $row->getElementsByTagName('td'); 

        /*** echo the values ***/ 
        echo $cols->item(0)->nodeValue.''; 
        echo $cols->item(1)->nodeValue.''; 
        echo $cols->item(2)->nodeValue; 
        echo '<hr …
nonshatter 26 Posting Whiz

"Permission denied" means that the file that you're trying to read from is protected somehow. Check the properties of that file or directory

C://xampp/htdocs/ $resource['txt'].
nonshatter 26 Posting Whiz

No probs darkdot. To extract just the ID from your table, replace the * with the column name of the PRIMARY KEY in your table pptext. * means select every column in the table.

A while loop is not required as you are only fetching one value from your table.

$fetch = ("SELECT ID FROM pptext",$link) or die(mysql_error());

$result = mysql_fetch_assoc($fetch);
echo $result['ID'];

Note: you may need to change "ID" to the name of the id column in your table

nonshatter 26 Posting Whiz

You have too many parenthesis after the sql query you have a ")" before the $link variable. Is that $link variable necessary?

nonshatter 26 Posting Whiz

Hi all,

I have a query pulling out dates from a database, these dates are then added to an array and inserted into a graph along the x-axis. From the results, there could be one value with one date or there could be 10 values with one date. This means that the data displayed on the x-axis is inconsistent. What I need to do is to add the unique dates ONLY to the array, which will allow the graph to have more clarity.

<?php
$get_testruns = mysql_query("SELECT testrun_id,logs,req_iter,comp_iter,tools FROM (testrun tr) left join log_servers ls on tr.log_servers_id = ls.log_servers_id WHERE test_codelevel_id='695259' ORDER BY end") or die(mysql_error());
	
	$x = 0;
	$y = 0;
	while ($result = mysql_fetch_assoc($get_testruns)) {
	
		$testrun_id = $result['testrun_id'];
		$getdate = mysql_query("select end from testrun where testrun_id = '$testrun_id'") or die(mysql_error());

		while ($date = mysql_fetch_assoc($getdate)) {
			$end = $date['end'];
                    // Need something here to process unique dates
			$formatted_date = date("d/m/Y",$end);
    		}

		$req_iter = $result['req_iter'];
		$comp_iter = $result['comp_iter'];
		
		$arrData[$x][1] = $formatted_date;    //x-axis
		$arrData[$y][2] = $comp_iter;    //y-axis
		  
		$x++;
		$y++;
	}
?>

Many thanks ;), Nonshatter x

nonshatter 26 Posting Whiz

Correct me if i'm wrong, but I think it might be because you're trying to print each row as an associative array when the results are returned as mysql_fetch_array.

Try this:

$row=mysql_fetch_assoc($result);
while($row = mysql_fetch_assoc($result))
nonshatter 26 Posting Whiz

You will have to add a new column to the table called gp2 or something. This will be the only way to assign a member more than one group. If a member only has one group, then their gp2 field should be NULL.

ALTER TABLE staff ADD COLUMN gp2 INT(5);

Then your php/mysql query will need to be changed such that it queries the new field:

"select * from staff where gp like \"%$var\" OR gp2 like \"%$var\" ORDER BY ord ";
nonshatter 26 Posting Whiz

This is an old function I used to use. Not sure how helpful it will be, but at least it shows how to give the image a unique name using time():

<?php

define("MAX_SIZE","100");

$errors = 0;

if (isset($_POST['upload'])) {
	$image = $_FILES['image']['name'];
		
	if ($image) {
		$filename = stripslashes($_FILES['image']['name']);
		$extension = getExtension($filename);
		$extension = strtolower($extension);
			
		if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) {
			$errors = 1;
			echo 'wrong extension';
		}
		else {
			$size = filesize($_FILES['image']['tmp_name']);
		
				if ($size > MAX_SIZE*1000) {
					$errors = 1;
					echo 'Sorry, the image is too large, Please specify another';
				}		
			//give unique name to image
			$image_name = time().'.'.$extension;
			$newname = "images/".$image_name;
			
			$copied = copy($_FILES['image']['tmp_name'],$newname);
			$_SESSION['img'] = $newname;

				if (!$copied) {
					$errors = 1;
				} 
		}
	}
}

//--- DETERMINES IMAGE EXTENSION ---//
function getExtension($str) {
	$i = strrpos($str,".");
		if (!$i) {
			return "";
		}
	$l = strlen($str)-$i;
	$exten = substr($str,$i+1,$l);
	return $exten;
}
?>
nonshatter 26 Posting Whiz

Can you post your table structure?

nonshatter 26 Posting Whiz

In order for the recipients to be generated dynamically, you will need to do a query to fetch the recipients:

<?php

$query = mysql_query("SELECT email_address FROM table WHERE date = someonesbirthdate");

// while there are result email addresses, add them to the recipients lists
while ($results = mysql_fetch_assoc($query))
{
    // multiple recipients array
    $to[]  = $results['email_address'] . ', ';
}
?>

The same would be required for the subject content. Just query the database and while results exist, put them into the a subject variable or array.

nonshatter 26 Posting Whiz

Undefined index means you're referring to an array with an index value that doesn't exist or can't be recognised. Try putting single quotes around the

$_POST['$id'];
nonshatter 26 Posting Whiz

First you will need an action to occur when a button has been clicked. If the html element had a value of 'directors' then you could do something like this:

$staff=$_POST['directors'];

if(isset($staff))
{
    $sql_query = mysql_query("select * from tablename where fieldname='$staff'") or die (mysql_error());
    while ($result = mysql_fetch_assoc($sql_query))
    {
         echo $result['fieldname'] ."<br>";
    }
}

Then do the same thing for different options eg admin, managers, students

nonshatter 26 Posting Whiz

The PHP tags must be opened and closed for the JavaScript, otherwise PHP won't interpret the <script> code. Like this:

<?php 

$terms = $_POST['terms'];

if($terms == "terms") 
{
    Redirect("http://www.romancart.com/checkavailability.asp?storeid=43296");
} 
else 
{
    echo "please accept terms and conditions";
}

// JAVASCRIPT REDIRECT FUNCTION
function Redirect($url) { ?>
	<script type="text/javascript">
		window.location = "<?php echo $url ?>"
	</script>
<?php 
}
?>
nonshatter 26 Posting Whiz

I'd stick with Javascript for redirects.

<?php
if($terms == "terms") {
    Redirect("http://www.romancart.com/checkavailability.asp?storeid=43296");
} 

// JAVASCRIPT REDIRECT FUNCTION
function Redirect($url) { ?>
	<script type="text/javascript">
		window.location = "<?php echo $url ?>"
	</script>
<?php 
}
?>
nonshatter 26 Posting Whiz

This could be due to a number of things. You may want to be a bit more specific rather than saying "it shows an error when I host it". What is your host? Is the directory structure on your host the same as in WAMPP? Are all the files there? Are the file paths set correctly?

nonshatter 26 Posting Whiz

Hi all,

I have a fairly simple question on something I know little about... Is there a PHP equivalent to the Perl POD? We're basically switching over from Perl to PHP but we are struggling to find a PHP-ish way of documenting from within our code. If anyone knows anything give me a shout!

Many Thanks,
Nonshatter

nonshatter 26 Posting Whiz

Try:

<table border="0" align="center" cellpadding="0" cellspacing="0">
	<tr> 
	  <td><img src="/_images/nav_divider_white.gif"></td>
	  
	  <?php while ($nav = @mysql_fetch_assoc($navigation)) { 
              if ($nav['fieldname'] == "company") {
              continue;
              }
          ?>

... remaining original code, etc. ...

...Replacing with the name of the mysql fieldname that company is located. Also, I can't see where $mainnav and $mainnav2 are coming from

nonshatter 26 Posting Whiz

Ah-ha! Previously I was using the cli to locate the php.ini file: (I assumed there would only be one)

# php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/conf.d
Additional .ini files parsed:      /etc/php5/conf.d/ctype.ini,
/etc/php5/conf.d/dom.ini,
/etc/php5/conf.d/gd.ini,
/etc/php5/conf.d/hash.ini,
/etc/php5/conf.d/iconv.ini,
/etc/php5/conf.d/json.ini,
/etc/php5/conf.d/mysql.ini,
/etc/php5/conf.d/mysqli.ini,
/etc/php5/conf.d/pdo.ini,
/etc/php5/conf.d/pdo_mysql.ini,
/etc/php5/conf.d/pdo_sqlite.ini,
/etc/php5/conf.d/sqlite.ini,
/etc/php5/conf.d/tokenizer.ini,
/etc/php5/conf.d/xmlreader.ini,
/etc/php5/conf.d/xmlwriter.ini

However, after issuing:

# locate php.ini
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

There was a dupe config file. One must control the cli config, and the other controls apaches config.

nonshatter 26 Posting Whiz

Hi, I have tried what nevvermind posted still without success. It's really puzzling me :S Any ideas?

nonshatter 26 Posting Whiz

I expect that he has permissions from that website to access their server/database. Do you have permission to access your chosen website? If not, then I don't think it's legally possible. What information are you trying to pull?

nonshatter 26 Posting Whiz

Sussy, Good question. I'm not 100% sure on how this would work but this article may get you on the right track for how to use sockets and ping.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=8&txtCodeId=1786

nonshatter 26 Posting Whiz

You're going to need to be a bit more specific in order for people to help!

nonshatter 26 Posting Whiz

I'm not sure entirely what you're trying to accomplish, but could this work?

$query = "SELECT SearchString,Count(SearchID)
FROM SearchString 
GROUP BY SearchString"; 

$result = odbc_exec($conn,$query);

// Print out result
$i = 0;
while($fetch=odbc_fetch_array($result)){

echo "There area total of ". $fetch[$i] ." Searches for ". $fetch['SearchString'] .".";
echo "<br />";
$i++;
}

All it's doing is incrementing the value of $i each time there is a valid result. So essentially it's counting the number of valid results? Let me know if this is not what you're looking for and I will try and help

nonshatter 26 Posting Whiz

I have found a temporary fix by putting this line of code in each of my scripts, but it's not ideal.

ini_set("display_errors","2");

Thanks

nonshatter 26 Posting Whiz

Acute, I adopted this one for one of my projects. It worked pretty well

http://evolt.org/node/60265/

nonshatter 26 Posting Whiz

Hey aycmike.
I know when I started learning I used a book called PHP and MySQL Web Development by luke welling and laura thomson which has lots of examples. Try and get the third/fourth edition though - you can get it second hand from Amazon for a decent price. There's tons of information available on the internet though, tiztag or w3schools is a good place to start. And the PHP Manual is useful for reference and examples.
Good Luck!

nonshatter 26 Posting Whiz

Hi all,

Just installed PHP 5.2.6 on SLES11. I have editted php.ini to try and turn error reporting on, but it's not turning on (I have restarted apache2). At the moment, I'm using php in cli to debug which is getting a bit stale...

Here's a section of my php.ini config:

error_reporting = E_STRICT
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off

Any ideas? Could something else (i.e. Apache) be preventing the errors from displaying?

nonshatter 26 Posting Whiz

Hey guys,

Apologies if this is posted in the wrong place, but couldn't find a suitable forum.

Basically I'm making a website for a musician, and was contemplating using WordPress to allow him to be able to manage his own updates, as well as update his image gallery, new videos and gigs so that he doesn't have to pay someone to maintain it for him. Would wordpress be suitable for this? How is wordpress used in industry? Does the site author give the client full access to wordpress to allow them to manage their site? I'm just unsure how the development/maintenance cycle works in terms of client manageability. Any advice/tips is much appreciated.

Many thanks,
Nonshatter

nonshatter 26 Posting Whiz

Do you have session_start(); at the top of your script?

nonshatter 26 Posting Whiz

hey guys,

I'm trying to simply use the mail function. I'm using ubuntu 8.10 and have installed sendmail. My php.ini config is:

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -i

and for testing purposes my php is:

$to = 'myemail@myemail.com';	
		$subject = 'test';
		$message = 'text';
		$headers = 'From: myemail@myemail.com' . "\r\n" .
    			'Reply-To: myemail@myemail.com' . "\r\n" .
    			'X-Mailer: PHP/' . phpversion();

			mail($to, $subject, $message, $headers);

		echo 'message sent';

Can anyone confirm whether this is correct or if i'm going wrong somewhere?
Thanks, nonshatter