cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Now I changed my mind and the site will only allow admins to login so now I need to modify the login just to suit admin needs but my problem is since it won't be wise to build a register script for admins
how do I add new admins!
I mean do I add admins account myself and just put the login there or something like that.
Can someone help me please?

Sounds like it's mainly the theory that has gone terribly wrong. I shall explain the answer and if you have any problems then I shall provide some code. So as explained you have a register script and a login script. That is all and good and now for the next stage. You will need to put into your config file a username variable and a password variable for the master username and master password. Then modify the login script to accept this master user. Then when the master user is logged in a cookie or session variable is set to say it is the master user. And add an if statement in the register script to check if it is the master user registering a new user. Then last of all make sure the register page is only linked to in the master admin panel and not in everybody else's admin panel and not in public domain. That's the theory and hope it gives you a better picture.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I believe that is the correct syntax however the files should be accessible with AND without rewritten urls. Also if you want to make sure apache doesn't get into an infinit loop causing a 500 error then you could use the following:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^nu.wetwork\.org\.uk
RewriteRule ^(.*)$ http://www.nu.wetwork.org.uk/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)/(.*)/?$ /index.php?adran=$1&tud=$2

So to explain what those last three lines do, the two lines near the end beginning with RewriteCond% check that it is not rewriting a file or directory. Then the last line matches the regex on the left in the url and if that matches it views the page on the right similar to the preg_replace syntax. Is that what your after because you may need to just try viewing it in the new format and linking to the new format as both ways exist when using mod_rewrite?

diafol commented: Brilliant! thank you very much - I was going off my rocker! +5
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Let me explain something to you about dictionaries: Those definitions that are listed first are considered the best definition; you offer us definition #5 just barely above guess or conjecture.. I read the links I post and I understand them. I think guess describes you idea perfectly. In order for you to have a system or method, you must offer more that "I think this so it must be correct".

I never said that my theories where 100% accurate or that they are even true. Check the work theory in the dictionary or from the movie "Darwins theory - The beagle voyage". You will find in that non-fiction film a scientific case that challenged Darwins theory. In that case the scientists had to define the word "theory". That definition was "An alternative view to a subject just like how gravity is a theory...". And using that definition I am providing theories not facts! The definition of the word "fact" is very different to the word "theory" as theories are not always true and are just another way of looking at the subject.
So with that being said my statements are theories and I strongly support/believe them...

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi and this function I wrote as part of a larger project and acts exactly like the php explode function. Although there a few slight differences between this function and the php explode function it can easily be tweaked to act identical. Also with this function it does not use vectors. Instead it uses an array as the result and in the result array, the combination being split will not appear in any of the strings just like the php function does.

In case your wondering how to use this function simply place in the string to split (param1) and where to split it (param2) then it will return an string array with the results. Hope you enjoy this function and that this page is a good reference...

Ancient Dragon commented: Nice :) +26
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Proof of ignorance

in user Cwarn23 we can see:
    he doesn't read links (given)
    he doesn't know proper higher maths (obvious)
    he ignores all valid points (drawn from answers)
Therefore Cwarn23 is obviously missing the point and not worth our time.

There we go, a pseudo mathematical proof with reasoning. And i think we can all listen to it. I certainly shall.

I wouldn't say that I'm ignorant but instead open minded. Exploring concepts that haven't been explored before and seeing if they can be true. When I'm worth a million dollars that will be a 1 million dollar quote. And I believe I could easily invent to AI algorithms for robotics when their tools are easily accessible.

@cwarn23
Consider yourself as 2-dimensional.(Forget your cube thing)
You live in a 2-dimensional world, together with other 2-dimensional people. So the only things you know are length and width. Now if you are all enclosed in a circle, nobody can escape. Remember you are 2-dimensional! Now there is some smart guy who knows 3 dimensions, he has the concept of height!!! So he can just dissapear before your eyes and even move outside the circle!
Now consider again. You are 3-dimensional and you are together with a smart guy inside a giant football. You cannot move outside the fooball, right? Well the smart guy knows what the fourth dimension is and just dissapears right before your eyes :-O
Through a hole in the football you can see him again …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Recently I have installed php 5.3 on a pc and just like many posts on this forum have been saying the latest version of php does not guarantee 100% backwards compatibility. Especially for some oop parameters where the symbol "&" needs to be used before the variable at specific points unlike php 5.2. Due to these changes php.net recommends for people to upgrade to 5.3 although I wouldn't recommend it myself if you have an existing scripts. Also if you want cms's like mediawiki to work under 5.3 then some modifications to the core of the script will be necessary. Just thought I would point this out as it explains a few of the problems posted in this forum and hopefully this can be made a sticky. Any comments on the issue are welcome...

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

So, apply an opposite force to achieve the objective.
If you guys just want to discuss why this can't be done and call me names, please go elsewhere. There's no theoretical reason a planet's orbit can't be changed.

I understand from a theoratical point of view you could achieve altering the planets orbit just like you can blow up the galaxy with a truck, a few pipes, a welder and a microwave - as shown on Macgyver and everything on that show has been proven true. So if we can blow up the galaxy with those items then why not change the orbit of a planet? I'm sure the scientists could speed up some groups of particles to the speed of light colliding with the planet but would require space travel. But it's all theoretical and not yet practical for humans to do. At least for the humans on earth.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

1) mostly work, not much free time for much else thanks to taking an extra A-level
2) something arty, i do love photography - though i'm currently lacking a camera until christmas :P
3) Go iceskating whenever I can, or an icehockey session whenever there's one on
4) Coding, only really do C/C++ and Flash Actionscript 2, but you can see here. [link]
5) Be with friends
6) Read books and magazines

Age of empires is a great classic, still have it :) haven't played it since I was about 12 though.

Age of Empires 2 - That's one of my favorite games too. I don't think the Microsoft Zone is running though so unfortunately we can't vs each other in Age of Empires 2. :( That's a shame.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

You need to connect to your MySql host first before making queries. Why not try:

mysql_query("root", "", "localhost");
$query="UPDATE ".$table." SET ".$sub_code."='".mysql_real_escape_string($dbc, $marks)."' WHERE no='".mysql_real_escape_string($dbc, $r_no)."' LIMIT 1";
mysql_query($dbc, $query) or die('error');

(The second argument of most MySQL functions is the connection variable which PHP adds or MySQL assumes by default if a connection has been made)

That won't work due to invalid syntax. The following would be more like it.

mysql_connect("localhost", "root", "password");
mysql_select_db('my_database');
$query="UPDATE ".$table." SET ".$sub_code."='".mysql_real_escape_string($marks)."' WHERE no='".mysql_real_escape_string($r_no)."' LIMIT 1";
mysql_query($query) or die(mysql_error());
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Everybody's reply to this thread should ultimately be "Replying to this thread".

Well I think the question is referring to just after your reply and after leaving the thread. But there is a limit to how many words you can fit in the title and that is where the confusion comes in.;)

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Although I rarley use that method to login I too find it annoying it doesn't work as every so often I forget that method doesn't work and get caught by the bug. Please fix dani.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Having dinner with friends who I only see on Xmas and Independence Day. I love them dearly but they have 3 kids and no time for us - life can be like that sometimes.

Independence Day? Is that the day where the aliens try to take over the world. When we would not give up without a fight. When we would not sleep quietly into the night. When we were going to live on and survive. At least that is what the movie says so did they name a day after that movie. That would be cool.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Is this a question? What do you want? Have you contacted the host? If you see php code you've probably not enclosed the code inside php tags or perhaps your hosting account does not support php.

Exactly and in addition to that your host may have turned off short tags in the php.ini file so you might need to use the full <?php .

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Here's a script from this article.

<?php
$pages_left=3;
$pages_middle=4;
$pages_right=2;
 
$total_pages=100;
if (!isset($_GET['page']) && empty($_GET['page'])) {
$currentpage=0;
} else {
$currentpage=$_GET['page'];
}
for ($p=0;$p<=$total_pages;$p++) {
    if ($p<$pages_left || $p>=($total_pages-$pages_right) || ($p>=($currentpage-floor($pages_middle/2)) && $p<=($currentpage+floor($pages_middle/2)))) {
        if ($p==$currentpage) {
        echo ($p>0)?' - ':'';
        echo '<b>'.($p+1).'</b>';
        } else {
        echo ($p>0)?' - ':'';
        echo '<a href="index.php?page='.$p.'"><b>'.($p+1).'</b></a>';
        }
    }
}
?>
kvprajapati commented: Great! +6
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

You can take a look at this thread for a script that already has some of those abilities programmed in. But there would be a lot more programming to add in. Alternatively there is a script I once used called Sphider which does exactly what you ask but I find hard to edit.

kvprajapati commented: Great script, Indeed. +6
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have a template that I can give you and it is as follows:

<form method="post">Scan site: <input type="text" name="site" value="http://" style="width:300px">
<input value="Scan" type="submit"></form>
<?
set_time_limit (0);
if (isset($_POST['site']) && !empty($_POST['site'])) {
/* Formats Allowed */
$formats=array('html'=>true,'htm'=>true,'xhtml'=>true,'xml'=>true,'mhtml'=>true,'xht'=>true,
'mht'=>true,'asp'=>true,'aspx'=>true,'adp'=>true,'bml'=>true,'cfm'=>true,'cgi'=>true,
'ihtml'=>true,'jsp'=>true,'las'=>true,'lasso'=>true,'lassoapp'=>true,'pl'=>true,'php'=>true,
'php1'=>true,'php2'=>true,'php3'=>true,'php4'=>true,'php5'=>true,'php6'=>true,'phtml'=>true,
'shtml'=>true,'search'=>true,'query'=>true,'forum'=>true,'blog'=>true,'1'=>true,'2'=>true,
'3'=>true,'4'=>true,'5'=>true,'6'=>true,'7'=>true,'8'=>true,'9'=>true,'10'=>true,'11'=>true,
'12'=>true,'13'=>true,'14'=>true,'15'=>true,'16'=>true,'17'=>true,'18'=>true,'19'=>true,
'20'=>true,'01'=>true,'02'=>true,'03'=>true,'04'=>true,'05'=>true,'06'=>true,'07'=>true,
'08'=>true,'09'=>true,'go'=>true,'page'=>true,'file'=>true);
 
function domain ($ddomain) {
return preg_replace('/^((http(s)?:\/\/)?([^\/]+))(.*)/','$1',$ddomain);
}
 
function url_exists($durl)
		{
		// Version 4.x supported
		$handle   = curl_init($durl);
		if (false === $handle)
			{
			return false;
			}
		curl_setopt($handle, CURLOPT_HEADER, true);
		curl_setopt($handle, CURLOPT_FAILONERROR, true);  // this works
		curl_setopt($handle, CURLOPT_HTTPHEADER, 
Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") );
		curl_setopt($handle, CURLOPT_NOBODY, true);
		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
		$connectable = curl_exec($handle);
		curl_close($handle);  
        if (stripos(substr_replace($connectable,'',30),'200 OK')) {
            return true;
            } else {
            return false;
            }
		}
 $fdata='';
//below function will only get links within own domain and not links outside the site.
function getlinks($generateurlf) {
    global $formats;
    global $f_data;
    $f_data=file_get_contents($generateurlf);
    $datac=$f_data;
    preg_match_all('/(href|src)\=(\"|\')([^\"\'\>]+)/i',$datac,$media);
    unset($datac);
    $datac=$media[3];
    unset($media);
    $datab=array();
    $str_start=array('http'=>true,'www.'=>true);
    foreach($datac AS $dfile) {
        $generateurle=$generateurlf;
		$format=strtolower(preg_replace('/(.*)[.]([^.\?]+)(\?(.*))?/','$2',basename($generateurle.$dfile)));
        if (!isset($str_start[substr_replace($dfile,'',4)])) {
            if (substr_replace($generateurle,'',0, -1)!=='/') {
                $generateurle=preg_replace('/(.*)\/[^\/]+/is', "$1", $generateurle);
                } else {
                $generateurle=substr_replace($generateurle,'',-1);
                }
 
            if (substr_replace($dfile,'',1)=='/') {
                if (domain($generateurle)==domain($generateurle.$dfile)) {
                    if (isset($formats[$format]) 
                        || substr($generateurle.$dfile,-1)=='/' || substr_count(basename($generateurle.$dfile),'.')==0) {
                        $datab[]=$generateurle.$dfile;
                        }
                    }
                } else if (substr($dfile,0,2)=='./') {
                $dfile=substr($dfile,2);
                if (isset($formats[$format])) {$datab[]=$generateurle.'/'.$dfile;}
                } else if (substr_replace($dfile,'',1)=='.') {
                while (preg_match('/\.\.\/(.*)/i', $dfile)) {
                $dfile=substr_replace($dfile,'',0,3);
                $generateurle=preg_replace('/(.*)\/[^\/]+/i', "$1", $generateurle);
                }
                if (domain($generateurle)==domain($generateurle.'/'.$dfile)) {
                    if (isset($formats[$format]) || substr($generateurle.'/'.$dfile,-1)=='/' 
                        || substr_count(basename($generateurle.'/'.$dfile),'.')==0) {
                        $datab[]=$generateurle.'/'.$dfile;
                        }
                    }
                } else {
                if (domain($generateurle)==domain($generateurle.'/'.$dfile)) {
                    if (isset($formats[$format]) || substr($generateurle.'/'.$dfile,-1)=='/' 
                        || substr_count(basename($generateurle.'/'.$dfile),'.')==0) {
                        $datab[]=$generateurle.'/'.$dfile;
                        }
                    }
                }
            } else {
            if (domain($generateurle)==domain($dfile)) {
                if (isset($formats[$format]) || substr($dfile,-1)=='/' || substr_count(basename($dfile),'.')==0) …
nav33n commented: nice! +5
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

When you program a computer game based on a dream you had...

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

@cwarn23, I think the OP was saying, that it shows only 1 record instead of 2 !

Maybe my explanation was too short. Sometimes people will do the following:

<?php
$connection = mysql_connect("myserver.com","myuser","mypassword") or die ("Couldn't connect to server."); 
$db = mysql_select_db("mydb", $connection) or die ("Couldn't select database."); 

$search=$_POST['search'];

$data = "SELECT firstname, lastname, task FROM inventors WHERE taskdate - curdate() = 1";
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
$data2 = mysql_fetch_assoc($query)
while($data2 = mysql_fetch_assoc($query)) {
echo $data2['firstname']; 
echo $data2['lastname'];
echo $data2['task']; 
echo '<hr>';
}
?>

However the above is incorrect and therefore should be replaced with the below.

<?php
$connection = mysql_connect("myserver.com","myuser","mypassword") or die ("Couldn't connect to server."); 
$db = mysql_select_db("mydb", $connection) or die ("Couldn't select database."); 

$search=$_POST['search'];

$data = "SELECT firstname, lastname, task FROM inventors WHERE taskdate - curdate() = 1";
  $query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
while($data2 = mysql_fetch_assoc($query)) {
echo $data2['firstname']; 
echo $data2['lastname'];
echo $data2['task']; 
echo '<hr>';
}
?>

Basically that additional line can chew that first mysql result therefore only the second in this post should be used.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

cwarn23 thanks for the elaboration.But are you trying to say that, the mysql insert will be executed in the below code as there is no exit after the header() -

if(something)
{
header("Location:new_url.php");
mysql_query($insert_query);
}

compared to the code below -

if(something)
{
header("Location:new_url.php");
exit;
mysql_query($insert_query);
}

That is correct from what I have read in the past.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Perhaps this:

<?php
mysql_connect(HOST,USER,PASS);
@mysql_select_db("db303278079") or die( "Unable to select database");
$query="SELECT * FROM restaurants";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
for ($i=0; $i<$num; $i++) {
$rest_name=mysql_result($result,$i,"rest_name");
$address=mysql_result($result,$i,"address");
$telephone=mysql_result($result,$i,"telephone");
$website=mysql_result($result,$i,"website");
$cuisine_type=mysql_result($result,$i,"cuisine_type");
$area=mysql_result($result,$i,"area");
$website=(empty($website))?'':", <A HREF=$website>'Website'</a>";
echo "<strong>$rest_name</strong>, $address, $telephone, ($cuisine_type), $area$website<br >";
}
?>
dmkc commented: helps a lot to show me where I'm going wrong, thanks for the help!! +0
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try adding the following to the top of your php file(s)

setcookie ('PHPSESSID', $_COOKIE['PHPSESSID'], time()+172800);
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi and I have been working on a simple problem but can't seem to find any solution and have tried browsing the net. My question is how do I append to an array. Below is the code I tried but still doesn't work.

String[] names={""};
            if (charcheck1==true) {
                String[] chartmp={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
                for (int j=0;j<chartmp.length;j++) {
                    names[names.length]=chartmp[j];
                }
            }
            if (charcheck2==true) {
                String[] chartmp={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
                for (int j=0;j<chartmp.length;j++) {
                    names[names.length]=chartmp[j];
                }
            }
            if (charcheck3==true) {
                String[] chartmp={"1","2","3","4","5","6","7","8","9","0"};
                for (int j=0;j<chartmp.length;j++) {
                    names[names.length]=chartmp[j];
                }
            }
            if (charcheck4==true) {
                String[] chartmp={"`","~","!","@","#","$","%","^","&","*","(",")","-","_","+","=","|","\\","[","{","]","}",";",":","'","\"",",","<",".",">","?","/"," "};
                for (int j=0;j<chartmp.length;j++) {
                    names[names.length]=chartmp[j];
                }
            }

According to several sites I was browsing the above code should work but for some reason doesn't and reports a java.lang.ArrayIndexOutOfBoundsException: 1 error. Does anybody know how I can append to the array and please keep it simple as I am just beginning to learn Java? Thanks.

peter_budo commented: Interesting question +11
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Can you guys refer to people and not 'you' I assumed you guys were talking to me at first since I was the last both, didnt realize you had an argument between each other :D

Well when I say the word "you" I refer to the reader. Sorry if it was a bit confusing as many things in this topic are confusing to the untrained eye.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I don't think that stargate is technically possible , because just the
computing power it needs far exceeds million times of world's most
powerfull supercomputer.and project blue book does not mention
anything about stargate.And Area 51 is incapable of doing these
experiments ( those are high eneargy physics experiments ) that
can be only done in places like CERN.

But it's fair enough to believe that anti gravity technology is there
and they are applying it on their fighters and war technologies.

That's why the technology was found pre-made in egypt and according to my religion we descended from the Ancients somewhere between 5 and 10 million years ago.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Looks like google doesn't let this language run on windows because windows is too popular. hehehe At least it will run on linux and mac. Unfortunate that it's not cross platform for all systems.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I tested the following keyword on google, yahoo and altavista and it seems to work perfectly.

link:google.com

The above search term will search for all pages that link to google.com Also it tells you how many backlinks exist simply by checking how many results occurred. Also another example is as follows:

link:daniweb.com
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well for those with a slow internet connection every 10 seconds the video will pause and buffer then continue. I hate how that happens but I guess there is no way around it.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Cool, discovered that the player has some impressive documentation at http://developer.longtailvideo.com/trac/wiki/FlashVars

Now that I have my player working, could anyone reading this review the quality of my first video tutorial at http://syntax.cwarn23.info/media/index.html

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

@cwarn23 are you sure you do not have any messages in Sent Items?
Whenever you send personal message if check box bellow post editing area is left checked you get copy stored in your Sent Items.

THANKS! That's where they are hidden. Before they used to be in the one folder (inbox I think) but something must have changed during the upgrade to move all the messages to the sent box because even messages that I didn't send are in my sent box. Thanks for that info as now they are no-longer lost.
I will leave this thread open in case anyone else wants a topic called "Bugs!" as there has been so many of them.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

"My God, he's taking over the World"

:)

:twisted: Indeed

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

PS: cwarn32 are these tutorials able to be viewed by us via youtube, etc? Thanks.

Now that's an idea. I was planning to add them to my website and submit the best ones to daniweb but I now that you mention it I will make youtube videos too.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi,
I have tried to view my private messages (pm's) and although at the top of the screen it says I have 42 messages I can only view 2 messages. The first message and the last I can view. Could somebody fix this as I like to occasionally read my pm's.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

How about a tutorial on pagination (this question has been asked n number of times) , carts, htaccess, image handling, regular expressions, ...

Wow, those are excellent suggestions. I will start them as soon as possible and I think the charts tutorial will be interesting as I have made php charts once before but haven't really used them.
Rep points added!

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Also don't forget to try the imap_mail() function.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well try adding the following line just before the mail function to see if the address to is being stored properly.

echo '<h1>'.$to.'</h1>';

It should display the email address and if it doesn't then your problem is that the variable $mail hasn't got any email address assigned.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then why don't yous just redesign how the reputation system works so that people can't destroy others rep. In other words why not make the reputation system less sensitive with a limit?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi and I am planning to make a bunch of tutorials. I would like to hear what sort of php/ajax tutorials people would like to see. I have heard in the past that some noobs would like a tutorial on making a blog. What else should I write tutorials about which you would enjoy reading/using?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Does anybody know how I would use sockets to tap into the SMS protocol for sending+receiving SMS messages. Basically, all I want to be able to do is setup a php script that will be able to act as the SMS server and send+receive the SMS's directly through the SMS network. But I don't want to send it to an sms provider as I'm trying to make my script the sms provider. Does anybody know how to do this because I don't even know how the sms protocol works.

kvprajapati commented: Good question! +14
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Actually it should be as follows:

<option value="0"   <?php echo ($installtype == "0" || $installtype == 0) ? "selected" : ""; ?> >Install with CPanel Info (can create  MySQL  DB  automatically)</option>
darkagn commented: Well spotted! +6
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well one of the things that I like about Ubuntu that I find hard with some other distributions that that it is easy to use. Is easy to use a bad thing because more complex=better? Also with Ubuntu you don't ever need to use a single command line. So are all these easy to use features what makes Ubuntu so bad? I might stay with Ubuntu because as it is I'm finding it difficult to setup a CentOS server in a Virtualbox where as Ubuntu has a wizard like tool (Synaptic Package Manager) that allows easy install with a GUI. Now that's what I call a good feature unlike those other versions that force you to use the command terminal.

kvprajapati commented: Of course it is. +13
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

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
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

Well to retrieve the entire page use file_get_contents() then preg_match_all() to filter to that table. Below is an example

<?
$var=file_get_contents('http://superdialcouk.dmshop.biz/numbers/0207/choose.php?dmb1_SessRef=2009-08-22_15-29-14_8068_0003');
$var=preg_match_all('/<table class="vert_centered_leaded" style="width: 100%;".*<tr>.*<tr>.*<\/tr>(.*<\/table>)/Us',$var,$array);
//print_r($array);
$var='<table class="vert_centered_leaded" style="width: 100%;">'.$array[1][0];
unset($array);
echo $var;
?>

Usually I only use curl if it involves pinging or posting to a server.

caps_lock commented: code is much appreciated, sorry for the late feedback +0
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Why not just try it and find out. That's one of the great things with having xampp or wamp/lamp. Because you can easily test it under a localhost environment with that software and I can tell you now, testing that won't crash a your computer unlike calculating pi to 1,000,000 digits using the bcmath library.

peter_budo commented: Good advice ;) +22
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try something like this

mysql_query('INSERT INTO lesson (subject, year, learningArea, objectives, ability) VALUES ("'.mysql_real_escape_string($onrow["subject"]).'", "'.mysql_real_escape_string($onrow["year"]).'", "'.mysql_real_escape_string($onrow["learningArea"]).'", "'.mysql_real_escape_string($onrow["objectives"]).'", "'.mysql_real_escape_string($onrow["ability"]).'"') or die(mysql_error());

You may also want to post what was on the line before this as it too may also have an effect.

tulipputih commented: Thanks for your explanation +1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I was thinking of a new project for making a bot that scans daniweb for information and enters useful information into a database then people can ask the website questions and php+mysql will provide answers in paragraph form for the user to read. Is this ok on the legal side of things as I have written bots for my personal use before and have made a tutorial. Also if this is ok by the mods then any help with the algorithm would be appreciated.

kvprajapati commented: So nice that work. Simple yet elegant. +4
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well if that website that php re-enters the password in uses $_GET tags and not $_POST tags then you can simply use the file_get_contents() function to retieve the information. If however the external website uses $_POST tags then you will need to use curl.
So the basic usage of file_get_contents for communicating with an external website is as follows:

<?
$page=file_get_contents('http://www.example.com/page?user=cwarn23&pass=820578wxz56240358');
?>

Btw, that's a fake password. Hope the above example helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

any other suggestion?

Could you please post the lines around $Valuechild=array(); and check that it also uses the right casing because I can only see half the picture here.

tulipputih commented: thanks for your help..hope the problem could be solved..I have tried so many ways to make a link from that array variable +1