cwarn23 387 Occupation: Genius Team Colleague Featured Poster

As soon as I see "Linux" and "Ubuntu" in the same comment, immediately tune out. If you want to use the poor-man's OS X, be my guest; but please don't ply it as a real Linux distro, as it ain't!

Well Ubuntu if my Favourite OS as Windoze is too slow and Windoze just can't keep up with the technology. And if you think Ubuntu is so good that it's not classed as Linux then good for you because it must be something better than Linux.

William Hemsworth commented: ... -2
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well from what I know about big sites like Youtube, tags are generally used for keywords when searching for a topic. Can be usefull if there is no description but for daniwebs where there is only descriptions to search (unlike image content), I would say the tags are useless.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

As faster as daniweb may seem the daniweb pages source code looks a lot cleaner around the headers.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This problem just keeps on happening. There are 2 solutions.
1. Download xampp using other method (eg. there are 2 methods - exe and zip)
2. Use wamp instead.

I myself have never had this problem with xampp so perhaps it is something with the latest version.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I would suggest following an ajax tutorial because your syntax looks a little weird. One that I know of is the tizag tutorials but a google search will reviel more.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try replacing your first function with the following:

//VOTE POLL -------------------------------------
    function makeVote(url, parameters) {
      var http_request;
      try{
		// Opera 8.0+, Firefox, Safari
		http_request = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("You need ajax enabled.");
				return false;
			}
		}
	}
 
      http_request.onreadystatechange = alertVote;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

Hope that helps

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Firefox rocks!!

I find that Firefox, IE, Safari and Crome allways crash on me every day. However when I tried Opera it was the only free browser I could find that would not crash after a few hours of browsing the internet. Why? Because I always have 15 to 25 tabs open all at the same time and in most browsers that just overloads the memory. So Opera is the best as it never crashes unlike all those other browsers. But haven't tried Netscape though but thought it was an extinct species.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Just for anybody reading this thread in the future, I have managed to complete my script with better reliability and is as follows:

function get_date($date,$timestamp=false) {
    if ($timestamp==false) {
        $timestamp=time();
        } else {
        $timestamp=round($timestamp);
        }
    if ($timestamp>=0) {
        return date($date,$timestamp);
        } else {
        if ($timestamp<-62168515200)  { die('This timestamp was during before the year zero there for will not be calculated'); }
        //calculate negative time
        $year=1970;
        for ($i=-1;$i>$timestamp;) { //year loop
            $year--;
            for ($k=31; $k>0;$k--) { //month loop (December)
                $month=12;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (November)
                $month=11;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (October)
                $month=10;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; } …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following code:

<?
mysql_connect('localhost','root','');
mysql_select_db('mydatabase');
if (isset($_POST) && !empty($_POST)) {
    function generate($sql) {
        $dat='';
        $var=mysql_query($sql);
        while ($data=mysql_fetch_assoc($var)) {
            $dat.='<tr><td>'.$data['lessonID'].'</td><td>'.$data['subject'].'</td><td>'.$data['learningArea'].'</td><td>'.$data['ability'].'</td><td>'.$data['form'].'</td><td>'.$data['skills'].'</td><td>'.$data['time'].'</td></tr>';
            }
        return $dat;
        }
    $table=0;
    $string='';
    if ($_POST['weight']['subject']>0 && !empty($_POST['subject'])) {
        $sql='SELECT * FROM `lessonplan` WHERE `subject` LIKE "%'.mysql_real_escape_string($_POST['subject']).'%"';
        $string.='`subject` NOT LIKE "%'.mysql_real_escape_string($_POST['subject']).'%" AND ';
        $sqlarray[$_POST['weight']['subject']][]=$sql;
        }
    if ($_POST['weight']['learningarea']>0 && !empty($_POST['learningarea'])) {
        $sql='SELECT * FROM `lessonplan` WHERE '.$string.'`learningarea` LIKE "%'.mysql_real_escape_string($_POST['learningarea']).'%"';
        $string.='`learningarea` LIKE "%'.mysql_real_escape_string($_POST['learningarea']).'%" AND ';
        $sqlarray[$_POST['weight']['learningarea']][]=$sql;
        }
    if ($_POST['weight']['ability']>0 && !empty($_POST['ability'])) {
        $sql='SELECT * FROM `lessonplan` WHERE '.$string.'`ability`="'.mysql_real_escape_string($_POST['ability']).'"';
        $string.='`ability`!="'.mysql_real_escape_string($_POST['ability']).'" AND ';
        $sqlarray[$_POST['weight']['ability']][]=$sql;
        }
    if ($_POST['weight']['skills']>0 && !empty($_POST['skills'])) {
        $sql='SELECT * FROM `lessonplan` WHERE '.$string.'`skills` LIKE "%'.mysql_real_escape_string($_POST['skills']).'%"';
        $string.='`skills` NOT LIKE "%'.mysql_real_escape_string($_POST['skills']).'%" AND ';
        $sqlarray[$_POST['weight']['skills']][]=$sql;
        }
    if ($_POST['weight']['time']>0 && !empty($_POST['time'])) {
        $sql='SELECT * FROM `lessonplan` WHERE '.$string.'`time` LIKE "%'.mysql_real_escape_string($_POST['time']).'%"';
        $sqlarray[$_POST['weight']['time']][]=$sql;
        }
    if ($table==1) {
        echo '</table>';
        }
    if (!empty($sqlarray) && isset($sqlarray)) {
        echo '<table border=1 cellpadding=4 cellspacing=0><tr bgcolor="#CCCCCC"><td>ID</td><td>Subject</td><td>Learning Area</td><td>Ability</td><td>Form</td><td>Skills</td><td>Time</td></tr>';
        krsort($sqlarray);
        foreach ($sqlarray AS $array) {
            foreach ($array AS $sql) {
                echo generate($sql);
                }
            }
        echo '</table><p>';
        }
    }
?>
<style type="text/css">
.class {
      border:0px;
      }
</style>
<form method="post">
<table border=1 cellpadding=0 cellspacing=0>
<tr>
    <td colspan=4 bgcolor="#CCCCCC">Enter Keywords here:</td>
</tr><tr>
    <td>Subject:</td>
    <td><input class="class" type="text" name="subject" value="<? echo htmlentities($_POST['subject'], ENT_QUOTES); ?>"></td>
    <td><select name="weight[subject]" style="width:100%">
        <option value="9">9
        <option value="8">8
        <option value="7">7
        <option value="6">6
        <option value="5">5
        <option value="4">4
        <option value="3">3
        <option value="2">2
        <option value="1">1
        <option value="0">0
    </select></td>
</tr><tr>
    <td>Learning Area:</td>
    <td><input class="class" type="text" name="learningarea" value="<? echo htmlentities($_POST['learningarea'], ENT_QUOTES); ?>"></td>
    <td><select name="weight[learningarea]" style="width:100%">
        <option value="9">9
        <option value="8">8
        <option value="7">7
        <option value="6">6
        <option value="5">5
        <option value="4">4
        <option value="3">3
        <option value="2">2
        <option value="1">1
        <option value="0">0
    </select></td>
</tr><tr>
    <td>Ability:</td> …
tulipputih commented: very helpful ..thanks :) +1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have just checked the database and now must check before I continue is the following form what your looking for or could you change it to what this code should be. So by the sounds of it, each column has a seperate text box to search in. The sample html code of what I am talking about is as follows:

<form method="post">
<table border=1 cellpadding=4 cellspacing=0>
<tr><td colspan=2 bgcolor="#CCCCCC">Enter Keywords here:</td></tr>
<tr><td>Subject:</td><td><input type="text" name="subject"></td></tr>
<tr><td>Learning Area:</td><td><input type="text" name="learningarea"></td></tr>
<tr><td>Ability:</td><td><select name="ability" style="width:100%"><option value="excellent">Excellent
<option value="good">Good
<option value="poor">Poor</td></tr>
<tr><td>Skills:</td><td><input type="text" name="skills"></td></tr>
<tr><td>Time (minutes):</td><td><input type="text" name="time"></td></tr>
<tr bgcolor="#CCFFCC"><td>Search Now:</td><td align="right"><input type="submit" value="Search"></td></tr>
</table></form>

If that html form contains the fields you would like then I shall create the php script that processes it.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

In case you want to make a custom function, the following code will do the job but is really slow. But this will give you something to play with.

<?
function get_date($date,$timestamp=false) {
    if ($timestamp==false) {
        $timestamp=time();
        } else {
        $timestamp=round($timestamp);
        }
    if ($timestamp>=0) {
        return date($date,$timestamp);
        } else {
        if ($timestamp<-100000000)  { die('This timestamp will take too long to calculate'); }
        //calculate negative time
        $year=1970;
        for ($i=-1;$i>$timestamp;) { //year loop
            $year--;
            for ($k=31; $k>0;$k--) { //month loop (December)
                $month=12;
                $day=$k;
                for ($l=24; $l>0;$l--) {
                    $hour=$l;
                    for ($m=59; $m>-1;$m--) {
                        $minute=$m;
                        for ($n=59; $n>-1;$n--, $i--) {
                            $second=$n;
                            if ($i==$timestamp) { break;break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break;break; }
                        }
                    if ($i==$timestamp) { break;break;break; }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (November)
                $month=11;
                $day=$k;
                for ($l=24; $l>0;$l--) {
                    $hour=$l;
                    for ($m=59; $m>-1;$m--) {
                        $minute=$m;
                        for ($n=59; $n>-1;$n--, $i--) {
                            $second=$n;
                            if ($i==$timestamp) { break;break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break;break; }
                        }
                    if ($i==$timestamp) { break;break;break; }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (October)
                $month=10;
                $day=$k;
                for ($l=24; $l>0;$l--) {
                    $hour=$l;
                    for ($m=59; $m>-1;$m--) {
                        $minute=$m;
                        for ($n=59; $n>-1;$n--, $i--) {
                            $second=$n;
                            if ($i==$timestamp) { break;break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break;break; }
                        }
                    if ($i==$timestamp) { break;break;break; }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (September)
                $month=9;
                $day=$k;
                for ($l=24; $l>0;$l--) {
                    $hour=$l;
                    for ($m=59; …
hbmarar commented: Thanks to cwarn for helping me +5
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have experimented with your problem and this appears to be a minor php bug. It seems to not handle negetive numbers properly. So to be able to do this job, you will need to make custom functions with loops that calculate the appropriate date. I will see what I can do as it won't be an easy task (due to leap years) but good luck.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I can't see a single line of php code in the code you've posted. I would suggest downloading a php form script or using the following script instead.

<?
if (isset($_POST['subject']) && $_POST['message']!=='')
    {
    $address = "your_real_email@domain.com"; //change this to the receiving address.
    $subject = "Website Email: ".$_POST['subject'];
    if ($_POST['name']!=='')
        {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br>
<br>
Yours Sincerely<br>
".$_POST['name']."</td></tr></table>";
        } else {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
        "</td></tr></table>";
        }
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
 
    mail($address,$subject,$body,$headers);
    }
//below displays the form while above processes it.
echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br>
<textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'>
<input type='submit' value='submit'></form>";
?>

The above script is a sample script I have made myself and should do the job fine.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The only thing that I'm slightly confused about your question is your table structure. Could you send a sample sql file or something? Also I would recommend having two columns per recorded keyword. So below is an example structure

valuefield | keyword1 | word1strength | keyword2 | word2strength
test       | fred     | 23            | george   | 11

However I can't see something along those lines in your database structure and can't even see how your tables relate to each other as there is no index key. So perhaps changing the design of your database might make it more efficient or do you disagree?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Sorry if this reply is a bit brief because it is getting late and so as a quick answer, if you have lets say one keyword called 'bob', your query should look like the following:

mysql_query('SELECT * FROM `table` WHERE `column1`="bob" AND `column2`="bob" AND `column3`="bob"');

If however you have 3 keywords and they are 'bob', 'test', 'fred' then your query would look like the following:

mysql_query('SELECT * FROM `table` WHERE (`column1`="bob" OR `column1`="test" OR `column1`="fred") AND (`column2`="bob" OR `column2`="test" OR `column2`="fred") AND (`column3`="bob" OR `column3`="test" OR `column3`="fred")');

I know that using the explode function to make an array of words then looping through the words to make the query string should do the job. If the above is what your looking for then let me know and tomorrow I'll construct the full code for you. But for now good night.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you don't have a basic understanding then perhaps you should check out this article. Also here is some source for basic usage:

<?
if (isset($_POST['subject']) && $_POST['message']!=='')
    {
    $address = "your_real_email@domain.com"; //change this to the receiving address.
    $subject = "Website Email: ".$_POST['subject'];
    if ($_POST['name']!=='')
        {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br>
<br>
Yours Sincerely<br>
".$_POST['name']."</td></tr></table>";
        } else {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
        "</td></tr></table>";
        }
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
 
    mail($address,$subject,$body,$headers);
    }
//below displays the form while above processes it.
echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br>
<textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'>
<input type='submit' value='submit'></form>";
?>

If you don't have a clue what any of that code means then you have some studying to do. That code only uses basic concepts which you would use in every day coding. So perhaps a few php tutorials might help.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I read that you have some tables and the layout of the tables. So exactly what is it your trying to do? Just that you haven't posted a question other than to solve the problem.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Wow, we definitely have complete opposite thoughts on it. I've dealt with some absolutely horrible spaghetti code that was created by having PHP echo all of the HTML. Not only do very few editors highlight HTML when they're inside of strings but if you're just using strings and heredoc and you still want to maintain good indentation and readability of the HTML then you might as well just exit PHP and write it directly.

<?php
  echo "<h1>Some Page Title</h1>\n";
  $some_variable = "Hello World!";
  while ($blahity_blah) {
    // some other logic we don't care about
  }
  // do some more random stuff
  echo '<h3>' . $some_variable . "</h3>\n";
  for (/* more random stuff */) {
    // blah
  }
  echo '<table>
  <tr><td>Hello!</td></tr>
  <tr>
    <td>World!</td>
    <td>Goodbye</td>
    <td>World</td>
  </tr>
</table>';
?>

Vs

<h1>Some Page Title</h1>
<?php
  $some_variable = "Hello World!";
  while ($blahity_blah) {
    // some other logic we don't care about
  }
  // do some more random stuff
?>
<h3><?php echo $some_variable ?></h3>

<?php
  for (/* more random stuff */) {
    // blah
  }
?>
<table>
  <tr><td>Hello!</td></tr>
  <tr>
    <td>World!</td>
    <td>Goodbye</td>
    <td>World</td>
  </tr>
</table>

The whole point of it is to separate display logic (HTML) from control logic (PHP). In my opinion you should almost never ie., only when absolutely positively necessary have PHP output HTML.

If you want perfect html and perfect php using my method then I would use something like the following:

<?php
//pre define tab indents
$t1=' ';
$t2='  ';
$t3='   ';
$t4='    ';
$t5='     ';
$t6='      ';
$t7='       ';
$t8='        ';
$t9='         ';
$t10=' …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Ok
That basically returned the page source. To filter it you would need to place that data into a variable then use the regex library to filter it. I'm not sure but you might be able to use variables in the command terminal. But why is it you can't use php as a cron job. Isn't it like standard? The following is an example command:

php /home/www/cron.php

If however you are looking for something that is client side and not server side I would suggest looking at php-gtk for windows.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well curl on its own actually hasn't got anything to do with php. Curl is a programming language which can be found at wikipedia and Curl is even a mathematics calculation. So as you can see, the name Curl is known to be a number of things but the one in php is actually called Client URL Library. The Client URL Library (php-curl) is open source so if you know c++/c then you should be able to download the source and embed it into your program. I'm assuming that's what you want.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Each to his own I suppose, but I reckon anyone who could understand while ($i++ < 3): should be able to understand the idea of a brace.
Still, I ain't arguing the point, just not convinced.

I agree but in my belief, you should only ever have one php opening tag and one php closing tag in a php file. Then all html output should be done through php functions because otherwise it gets too confusing. And it's easier to manage that way.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The following code should do the trick:

<? echo date('j-n-Y'); ?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Perhaps instead of a live spell checker, instead have a spell check button which then uses ajax to check+correct the spelling. That would be the easiest way of doing it.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

preg_replace gives me the cr[e]ep$.

Well I find preg_reglace and regex to be fun, easy but almost useless.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try this:

<?
$stringa='This is a test';
$stringb='This is a tests';
similar_text ($stringa,$stringb,$percent);
echo round($percent,2).'%';
?>

Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Use google and search for bbcode classes.

Why use classes when one long line of preg_replace will do the job. Using preg_replace once for the job will do the job better then what any class will ever do.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If the error saying "store is empty" did not trigger then I would suggest checking what those two variable contain. So run the following code to make sure that the variables are set correctly.

$list = file_get_contents($imgpath);
$listarray = array();
$listarray = explode("\n",$list);
$count_line = count($listarray);


$key = array();
$newline ='';
$store ='';
for($i =0; $i <= count($listarray) ; $i++)
{
$name = $listarray[$i];

// Replaces the Empty Line
$line = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', $name);
$line = trim($line);
if($line !='')
{
// Apply URL

$line = link($line);

$fault =0;
$key[] = $line;
$store .= trim($line)."\r\n";
}
}
die('<h1>$imgpath</h1>'.$imgpath.'<br><h1>$store</h1>'.$store);
/*$fp = fopen($imgpath, 'w');
fwrite($fp, $store);
fclose($fp);*/
file_put_contents($imgpath,$store);
header("location: index.php");

Also make sure $imgpath is a relative path and that the directories in it's path already exist.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

PHP has built-in constructs that make it look like a templating language so you don't need the bloat of another templating class. I also prefer this method as people dealing with the files don't have to know what braces mean but its obvious what endwhile means.

<?php while($row=mysql_fetch_array($result)): ?>
  <td><?php echo $row['firstname'] ?></td>
  <td><?php echo $row['lastname']?></td>
<?php endwhile ?>

Sure that sometimes works ShawnCplus however you cannot have a loop inside a loop using that method. An example of invalid code is as follows:

<?php $i=0
while ($i<3):
    $i++;
    while($row=mysql_fetch_array($result)): ?>
      <td><?php echo $row['firstname'] ?></td>
      <td><?php echo $row['lastname']?></td>
    <?php endwhile
endwhile ?>

The above code will never work because you cannot have a while loop inside a while loop when not using brackets. So best practise is to use the brackets.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

i was wondering how to how seprate php from html while fetching rows from database..

<?while($row=mysql_fetch_array($result))
{?>
<td><?$row['firstname']?></td>
<td><?$row['lastname']?></td>
<?}?>

can i separate php and html in above case.>?
thank u

If I was coding this it would look like the following:

<?
while($row=mysql_fetch_assoc($result))
{
echo '<td>'.$row['firstname'].'</td>';
echo '<td>'.$row['lastname'].'</td>';
}
?>

Hope that helps you understand.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Found the problem.
I forgot to add id="q" in the input field. And this was thanks to the discover of the Opera debugger which can be enabled through the preferences list. In my opinion Opera has the best debugger in the World Web as it tells you the near exact error line and a few related lines.
*Solved*

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi and I'm no noob 2 ajax and have used it many times before. But for some reason this script doesn't want to work on any browser except Internet Explorer. Can anybody see what I have done wrong in this code as I have searched and searched for hours and only found things that don't work. I have another script that works that is almost identical to this one so I'm not sure what could possibly be wrong.

<script language="javascript" type="text/javascript">
function returnObjById( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
}
</script><script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function new_chatroom(var1){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			returnObjById("resultsfield").innerHTML = ajaxRequest.responseText;
		}
	}
    // Create a function that will receive data sent from the server
    ajaxRequest.open("GET", "'.$danibot['scriptpath'].'/extensions/danibot/results.php?q="+returnObjById("q").value, true);
	ajaxRequest.send(null); 
    }
//-->
</script><script language="javascript" type="text/javascript">
//http://www.cs.tut.fi/~jkorpela/forms/enter.html
function noenter() {
  if (window.event && window.event.keyCode == 13) {
    getresults();
    }
  return !(window.event && window.event.keyCode == 13); }

</script>

Please help.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well looks like you will need to have a separate file to refer to. To do this first create a new file with the following code:
image.php

<? //this is the entire page
echo file_get_contents('http://newpics.huntsvillecarscene.com/photos/random.mg?AlbumID=1626430&Size=Th&AlbumKey=eBBAU&rand=8075');
?>

Then make a html image take to that file like the following:
index.php

<?
echo '<img src="image.php">';
?>

But make sure those 2 files are in the same directory.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Just to let all the moderators know, the bot has now been launched.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have found out that to yum install curl the following commands may be used:

yum install php-curl
yum install curl

However that does not work on all servers and may need to be compiled from the source. Since that didn't work for me and I didn't have the slightest clue on how to compile from the source I paid support to do it for me. So with my extensions now installed, I am a happy customer and the daniweb bot is now online.
*Solved*

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well file_get_contents() is the simplest solution and another solution is curl. However file_get_contents() only works if you place the http:// at the beginning of the address and the complete url. So for example try the following:

file_get_contents('http://newpics.huntsvillecarscene.co...BBAU&rand=8075');

Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try replacing your code with this:

$query="SELECT * FROM player ORDER BY lname ";
$result=mysql_query($query); 

echo "<option selected>-- Select Player --</option>";
if (mysql_num_rows($result)>0) {
print("<option value=\"\">No Players On Roster</option>");
} else {
while ($row=mysql_fetch_assoc($result)) { 
echo '<option value="'.$row['id'].'">'.$row['fname'].' '.$row['lname'].'</option>';
}
}
//mysql_close;
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

WAMP have never let me down
http://www.wampserver.com/en/

I have a question for you. Does wamp have a control panel to restart services? Just a thing that comes with xampp that I'm not sure about wamp.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well he posted the exact same pic as I did, only 1 day later. So he could've seen my post :icon_wink:

I didn't realise this was about pictures. I better click the link then
...
Wow that's the picture your talking about. lol

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well I would suggest downloading the zip from this link (wait for the advertisements) then extract it. I myself haven't used this method so I will advise as you go along. It may have an auto extractor which will automatically send the files to the right locations or you might need to extract the files to C:/xampp Do that then post the results and what method you used.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Read the post above yours very carefully Grim ;)

I think he was refering to the post before that. So he should of had the following quote in his post.

Which reminds me: XKCD made this a few days back, which I found very handy. So I mailed it to all the people who constantly asked me questions about computers. The next day I got all kinds of questions asking how to save it, how to print it, why the printer didn't work or why the picture came out of the completely wrong

Probably find somebody posted while he was typing. Happens to me all the time. Would be nice if the browser lets you know if any new posts have been submitted before you submit the post. Or at least only when somebody else has posted before you.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Linux/Unix Note:
After compiling the extension you will need to move the .so file to the extension directory then uncomment the extension from the php.ini file. After that you may restart apache then php should recognise the new modules/extensions. Just a thing I learn't when trying to get my extensions installed but never could get them to work anyways.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Sounds like you might have downloaded the development version. Try downloading each Windows version and try each one until you find one that works. If that doesn't work then could it be because your running Windows Vista?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Did you try my version anyway because I added 3 lines you wouldn't have had before and see if the page ends early with an error message telling you the problem.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have checked your code and although it's a bit messy and buggy, a corrected version (still messy) is as follows:

$list = file_get_contents($imgpath);
$listarray = array();
$listarray = explode("\n",$list);
$count_line = count($listarray);


$key = array();
$newline ='';
$store ='';
for($i =0; $i <= count($listarray) ; $i++)
{
$name = $listarray[$i];

// Replaces the Empty Line
$line = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', $name);
$line = trim($line);
if($line !='')
{
// Apply URL

$line = link($line);

$fault =0;
$key[] = $line;
$store .= trim($line)."\r\n";
}
}
if (strlen($store)==0) {
die('<h1>Store is empty!</h1>');
}
/*$fp = fopen($imgpath, 'w');
fwrite($fp, $store);
fclose($fp);*/
file_put_contents($imgpath,$store);
header("location: index.php");
almostbob commented: thanks, writing the script, I can do, debugging, i can only ask to post the code for someone Good at it to look at +3
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

There is a long list of hosts located at http://www.webhostingchoice.com.au/ and I would suggest checking each one to see which one with mssql suits your needs best. Note that the table doesn't reviel if the host supports mssql but you will need to go to their website via link to check if the ones you like do have mssql.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I don't ask too many questions, in part because I try to RTFM.

If your trying to read the c++ manual then where is the c++ manual or is cplusplus.com it.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

After a lot of googling and experimenting in a test environment I managed to find a thing call "yum install". I have one question before I do this on my vps and that is - Are these commands sufficient to install the curl and gd libraries? They are as follows:

yum install php-gd
yum install php-curl

And the links I found about these from:

Links:
 Curl
 http://www.linuxquestions.org/questions/linux-newbie-8/yum-install-php-curl-trouble-631681/
 Above link has code that might be slightly misleading
 http://www.eukhost.com/forums/f30/how-install-php-curl-php-ssl-5704/

 Gd
 http://www.rasyid.net/2008/02/02/install-php-gd-in-centos/

Hope somebody can answer this question but in the mean time I will see if I can test on my testing environment but will be hard since there is a forbidden error in my test environment.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Once I have the end variable is it advisable to unset() the ones I don't use any more? Does this just use up more resources than it gains?

Well if it is a variable that is a few kilobytes in size and there is plenty of time left to execute then for sure use unset() to save resources. Also if your making a script that takes minutes or hours or even days to execute then unset may need to be used all the time to prevent memory leaks. And I haven't confirmed this yet but there might be something wrong with the bcmath library which requires unset(). So their your basic uses but as for regular variables like numbers/integres you shouldn't need to unset.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well installing is just as easy as downloading if the download the right file. Download the xampp package and installation explains itself. Also after installing xampp you will need to go to the xampp control panel to turn on mysql and apache/httpd. The link for it is http://www.apachefriends.org/en/xampp.html