cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Thanks cwarn23, I have already checked that.
WBR

Just a note that before I forgot to type, a localhost server can have around 3 php.ini files while only one of them are active. So that is why I recommend using the phpinfo() function to find out which php.ini file is the real one. And could you also check the phpinfo() function to see if the mysql module (not mysqld) has been loaded and is on the phpinfo() list.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

With this kind of error it is common that a module in your php.ini file is commented. So in your php.ini file, uncomment the line that says:
;extension=php_mysql.dll
To uncomment the line simply remove the ; symbol at the beginning of the line. Also the php.ini file can be found with the phpinfo() function. Also be sure to make a copy of your php.ini file before making any changes.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

}

$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {

if (mysql_error()) $logger->write(mysql_error(), 'ERROR');

}

return $result;

}

function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {

reset($data);

if ($action == 'insert') {

$query = 'insert into ' . $table . ' (';

while (list($columns, ) = each($data)) {

$query .= $columns . ', ';

}

$query = substr($query, 0, -2) . ') values (';


Thank you for helping.

I noticed a few errors in that script. One is the sql linker will need the extra dollar sign removing and is shown as follows:

$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

//above may need replacing with below:

$result = mysql_query($query, $link) or tep_db_error($query, mysql_errno(), mysql_error());

Also the line return $result; may also cause an error if it is not within a box. By saying a box, I meen a function, a external to internal command call (eg. include() ) or oop object. If the return is not in a box then from my experience, it will just return the $result status and prevent further executing of the php file and may even cause an extra error during the process.
But that $$link variable should really be changed and hope it helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try making the following your script:

<?php
session_start();

if((isset($_POST['username']) && $_POST['username']!="") && (isset($_POST['password']) && $_POST['password']!="")){
$error=''; 
$conn = mysql_connect('localhost','compkcom_care','ptk')or die('Could not connect to MySQL database. ' . mysql_error());
mysql_select_db(SQL_DB,$conn);
$query = "SELECT COUNT(username) AS record FROM admin WHERE username ='" . $_POST['username']."' AND password = '".$_POST['password']."'";
$result = mysql_query($query);
if (mysql_num_rows($result)>0) {
    $row = mysql_fetch_array($result);
    }
if($row['record']==1){
$_SESSION['user_logged'] = $_POST['username'];
$_SESSION['user_password'] = $_POST['password'];
header("location:welcome.php");
}
else{
$error .="Please+Enter+Correct+Username+and+password%21%0D%0A";
header("location:index.php?&error=".$error);
}
}
else{
$error .="Please+Enter+the+Username+and+password+First%21%0D%0A";
header("location:index.php?&error=".$error);
}
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try placing the following at the top of your php file(s) that process the uploads:

ini_set ('upload_max_filesize','10M');

That should allow the server to accept 10 Megabyte files and is the most common solution for this problem from previous posts of simular/same problems on these forums. Let me know if you need more info.

Glad to see you didn't back onto a 3 year old post :icon_biggrin:

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have looked up a few functions in the manual and although I can't find GetValueSQLString you could probably simplify the equation to the following:

$query_recpayment="SELECT * FROM `paymentsummary` WHERE `username`='".mysql_real_escape_string($_SESSION['MM_Username'])."' AND `foryear`='".mysql_real_escape_string($_SESSION['MM_yearlynow'])."' AND `forlevel`='".mysql_real_escape_string($_SESSION['MM_yearlevels'])."'";

Hopefully that mysql query will do the trick. Also note I used an apostrophie surrounding the column names and not comas. Very important to note the difference. The Apostrophie key is found to the left of the number 1 key on the keyboard.

The reason why I prefer to use apostrophies is when sharing open source code like on these forums, there are some servers that are really picky like one I use to be on which force you to use the apostrophie. So the reason why my preference is to use the apostrophie is to garantee compatability in those rare situations like I have been in before.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try resetting the variable $query_recpayment to the following:

$query_recpayment = "SELECT `amountpaid`, `username`, `amountpaid` FROM `paymentsummary` WHERE `username` = '%s' AND `foryear` = '%s' AND `forlevel` ='%s'";

As you can see the end part had a long php syntax error since a variable cannot assign those extra values in the format of which you did. Also I believe there was a mysql syntax error where it says `amountpaid`. Also in addition, I added the appropriate quotes to solve any escaping string errors (mysql errors). If you need the extra values that were added at the end then please explain what they were for so I can help place them appropriately.

PinoyDev commented: Vey Helpful. +1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

It's an oop (Object Orientated Programming) error saying that you are treating a function as an object. Mainly it says the function getStrippedName() is not an oop object and has been called as an oop object. So there are 2 solutions. You could convert the function getStrippedName() into an object or you could use a non-oop method of calling the function.
Examples are:

<?
// oop - example 1
$var = new getStrippedName();

// oop - example 2
$var->getStrippedName();

// non-oop
$var=getStrippedName();
?>

So to make your script work, you will need to use the third example in the above box where you don't use the arrow or the word 'new'.
Hope it helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well for the phpbb cms I will have a look for any hacks to do this but codewise it is the following line which needs to be configured weather you can do it though the config file or if a hack is needed:

mysql_connect('localhost', 'mysql_user', 'mysql_password');
//above needs to be changed to
mysql_connect('website.com', 'mysql_user', 'mysql_password');

So I will check out phpbb for you as it may be possible to do it through the config file.
---------------
Edit:
I just tried installing phpbb3 from a remote database and it appears what you need to do is first install phpbb3 on the server which supports mysql and at the same time specify the domain instead of localhost as the connection address. Then after installation, confirm in the config.php file that mysql is set to load from the remote server (currently the current server) and is not set to localhost. After that, you may transfer all the files to the other server that hasn't got databases and should read the remote server as it was specified during installation. The reason why the files need to be installed on the server with mysql is because of a validator that checks what types of databases are available.

diafol commented: Thanks for the help +3
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This is a very old thread, but it was the #1 hit with my particular error.

I found that the PHP in_array() function will give the "wrong datatype for second argument" warning if the array you are checking is empty or null. In this case, it appears that PHP doesn't know the type of data for the array argument, even if you define it as an array. I even tried defining it as global and it did not help.

A quick solution for me was to create a new in_array() function that wraps the built-in function, but checks the length of the array first.

function my_in_array( $needle, $haystack ) 
{
	if (sizeof($haystack) > 0)
	{
		return in_array($needle, $haystack);
	}
	return false;	
}

Probably because you are using a variable in the haystack instead of an array input. So I have added a validator the will only return true for arrays that match (and not variables) and the script is as follows:

function my_in_array( $needle, $haystack ) 
{
	if (sizeof($haystack) > 0 && is_array($haystack))
	{
		return in_array($needle, $haystack);
	} else {
	return false;	
    }
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try something along the lines of the following:

mysql_query("SELECT * FROM `table` LIMIT 0, 10")
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Thanks for that.
If I've dry run your code properly, a problem I can see is that by appending everything after element 3 onto element 3, if there was a location, it will also get appended onto element 3.
Then when you explode by ":" it would be element 2, which would not be picked up by the results.

I had hoped the code could be kept simple by using a regular expression as Details is an unknown input and could potentially contain anything.

Thanks for your replies.
Ralf

If you are saying that you want another array or field then the following should allow for the location array providing it remains called "location:" (without the quotes)

<?
$string =  'Name: Bob, Age: 20, Details: Likes chocolate, cake and fishfingers, Location: New York';
  $properties = explode(",", $string);
  $result = array();
  $joinid=3;
  $join='details';
  while(isset($properties[$joinid])) {
  if (!preg_match('/[ ]location\:/i',$properties[$joinid]) && $join=='details') {
      $properties[2].=','.$properties[$joinid];
      unset($properties[$joinid]);
      } else {
      if ($join=='details') {
          $join='location';
          $properties[3].=$properties[$joinid];
          } else {
          $properties[3].=','.$properties[$joinid];
          }
      unset($properties[$joinid]); 
      }
  $joinid+=1;
  }
  foreach($properties as $property) {
    $split = explode(":", $property);
    $result[$split[0]] = $split[1];
  }
  echo "<xmp>";
  print_r($result);
  echo "</xmp>";
?>

Hope that helps answer it.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I dont know but it keeps the button diabled even if the session variable is unblock.

I have checked my samples and they all seem to work which makes me wonder if your session is really being set to unblock. Because when for example running the page with the following code, the button will not be disabled:

<?
session_start();
/* then more php code
 * $_SESSION['MM_enrolltype'] should = 'block' or 'unblock'
 */
 
 
 
 
$_SESSION['MM_enrolltype']='unblock';
?>
<script language="JavaScript">
var buttonstatus = '<? echo $_SESSION['MM_enrolltype']; ?>';
function changebuttonstatus() {
if (buttonstatus=='block')
    {
    buttonObject1.style.display='none';
    buttonObject2.style.display='inline';
    buttonstatus = 'unblock';
    } else {
    buttonObject1.style.display='inline';
    buttonObject2.style.display='none';
    buttonstatus = 'block';
    }
}
</script>
 
<style>
<?
if ($_SESSION['MM_enrolltype']=='block') {
    echo "#buttonObject2 {display:none}";
    } else {
    echo "#buttonObject1 {display:none}";
    }
?>
</style>
<a href="javascript:changebuttonstatus()">Change button status</a>
<p>
<div id="buttonObject1">
<input type='submit' name='Submit' value='Enroll Now' disabled />
</div><div id="buttonObject2">
<input type='submit' name='Submit' value='Enroll Now' />
</div>
<?
 
 
 
 
//more php code
?>

So to check if this is the case, just place echo $_SESSION['MM_enrolltype']; at the end of the page and see what that variable is really set to when you embed the above script into your code.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

...
"Amazing how php doesn't know if it is using too much cpu." - So you're asking for a separate performance-analysis-daemon that is started with every skript, right?

Well I am just saying that the php libraries should take longer to execute and there for taking less cpu instead of having to use the sleep() function for extreamly large scripts. Or maybe even have an ini priority number for how fast/cpu hungry the script should be.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

If you are talking about to put the php variable into the javascript code then the following will do the job:

<?
session_start();
/* then more php code
 * $_SESSION['MM_enrolltype'] should = 'block' or 'unblock'
 */




$_SESSION['MM_enrolltype']='block';
?>
<script language="JavaScript">
var buttonstatus = '<? echo $_SESSION['MM_enrolltype']; ?>';
function changebuttonstatus() {
if (buttonstatus=='block')
    {
    buttonObject1.style.display='none';
    buttonObject2.style.display='inline';
    buttonstatus = 'unblock';
    } else {
    buttonObject1.style.display='inline';
    buttonObject2.style.display='none';
    buttonstatus = 'block';
    }
}
</script>
 
<style>
<?
if ($_SESSION['MM_enrolltype']=='block') {
    echo "#buttonObject2 {display:none}";
    } else {
    echo "#buttonObject1 {display:none}";
    }
?>
</style>
<a href="javascript:changebuttonstatus()">Change button status</a>
<p>
<div id="buttonObject1">
<input type='submit' name='Submit' value='Enroll Now' disabled />
</div><div id="buttonObject2">
<input type='submit' name='Submit' value='Enroll Now' />
</div>
<?




//more php code
?>
PinoyDev commented: very helpful, very good.! +1
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well at the moment your code should should be as follows if you want to use php:

<?php
session_start();
//above line (session_start) must be at the very top.
 
if ($_SESSION['MM_enrolltype']=="block") { 
    $disables =""; } 
else { 
$disables ="disabled"; }
 
echo "<input type='submit' name='Submit' value='Enroll Now' $disables />";
?>

Then if you want to use javascript to hide the button instead of having to wait for the page to load then there is a script at http://www.winfolinx.com/tips/howto/various/hidetext.htm which shows your code would look like the following:

<script language="JavaScript">
var buttonstatus = 'off';
function changebuttonstatus() {
if (buttonstatus=='off')
    {
    buttonObject1.style.display='none';
    buttonObject2.style.display='inline';
    buttonstatus = 'on';
    } else {
    buttonObject1.style.display='inline';
    buttonObject2.style.display='none';
    buttonstatus = 'off';
    }
}
</script>

<style>
#buttonObject1 {display:none}
</style>
<a href="javascript:changebuttonstatus()">Change button status</a>
<p>
<div id="buttonObject1">
<input type='submit' name='Submit' value='Enroll Now' disabled />
</div><div id="buttonObject2">
<input type='submit' name='Submit' value='Enroll Now' />
</div>

Note: the second code box has no php.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The line session_register( $_SESSION['MM_enrolltype']); does not need to be used in the way it is used because from what I have read in the documentation, it makes a variable a global variable and $_session's are allready global. So there is no need to use that line in this case and just as a note, the function session_register() has been depreciated which means in php version 6.0.0 that function will nolonger exist since global variables were proven to be so insecure. So I would recommend removing that line.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

That's a good solution, thanks!
The only problem is if there were commas in the details section, eg:
"Likes chocolate, cake and fishfingers". Any ideas?

Also, out of interest, is explode more efficient than regular expressions? The examples I gave were only a small section of a larger page.

Thanks again,
Ralf

Well the following code should solve that for you:

<?
$string =  'Name: Bob, Age: 20, Details: Likes chocolate, cake and fishfingers';
  $properties = explode(",", $string);
  $result = array();
  $joinid=3;
  while(isset($properties[$joinid])) {
  $properties[2].=','.$properties[$joinid];
  unset($properties[$joinid]);
  $joinid+=1;
  }
  foreach($properties as $property) {
    $split = explode(":", $property);
    $result[$split[0]] = $split[1];
  }
  print_r($result);
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Would this be the answer:

<?php
session_start();
//above line (session_start) must be at the very top.
$_SESSION['MM_enrolltype']='block';
 
 if ($_SESSION['MM_enrolltype']=="block") { 
    $disables =""; } 
 else { 
$disables ="disabled"; }
 
echo "<input type='submit' name='Submit' value='Enroll Now' $disables />";
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

2)Can we pass input value by using Javascript Sessions...

Just to let you know, Javascript Sessions are called Cookies. The client side version of Sessions. More can be found about cookies at http://www.w3schools.com/JS/js_cookies.asp

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have tested it and I think it's a html syntax error. This works for the Opera browser:

<?php
$totalbill = mysql_real_escape_string($row_reclog['total']);
if($totalbill==0.00) { $disables=""; } else { $disables=" disabled"; }
echo "<input type='button' name='button' value='Enroll Now'$disables>";
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

To help, I have removed the second session tag and fixed the problem of detecting if a session is empty:

<?php
session_start();
if(empty($_SESSION['username'])){
header("location: pleaselogin.php");
}

?>
<div class=linkstop>
<div class=textstyle>
<h2><a href="your_acc.php"><FONT COLOR="#666666">Your Account</FONT></a> | <a href="inbox.php"><FONT COLOR="#666666">Inbox</FONT></a> | <a href="bloghome.php"><FONT COLOR="#666666">Your Blog</FONT></a> | <a href="yourwall.php"><FONT COLOR="#666666">Your Wall</FONT></a> | <a href="galleryhome.php"><FONT COLOR="#666666">Your Gallery</FONT></a> | <a href="your_settings.php"><FONT COLOR="#666666">Your Settings</FONT></a></h2>
</div>
<div class=profilechooseform>
<?php
$name1 = $_SESSION['1stname'];
$name2 = $_SESSION['2ndname'];
echo "Welcome, ";  
echo $name1 ." " .$name2;
echo "<br>";
?>
<a href="logout.php"><FONT COLOR="#666666">Log Out</FONT></a>
<br> 
Search for someone's profile:
 <form action="searchresult.php" method="GET" name="view_profile">
 <input name="result" type=text />
 <input name="Go" type="submit" value="Search" />
 </form>
</div>
<br>
</div>

And as for the font tags, I believe that browsers will support them for some time because why would a software developer remove features from their own software. Won't happen for as long as it doesn't cause a problem and as far as I am aware font tags don't cause a problem.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just checked the official documentation and although it can be useful to jump out of loops to before the loop had began, I found the effects of using it incorrectly could cause a fatal server error (example: crashing apachie) Below is an example of escaping the loop.

<?php
$gotostart=0;
start:
$gotostart+=1;

//some code
echo "This is before the loop<br>";

$statement=0;
while($statement<5)  {
    //some code
    echo "This is in the loop before repeat<br>";
    if ($gotostart<3) {
    goto start;
    }
    echo "This is in the loop after repeat<br>";
    $statement+=1;
}
echo "Page loaded.";
?>

So with the above example, it will process the loop once without repeating the loop then will goto the start. After that the script will go through the loop again but won't repeat the loop so the loop acts like if there is no loop at all. Then when it reaches the goto again and will process the script again but on this third time it will repeat within the loop without the goto 5 times. Then will continue with the rest of the script. So the only alternative to the not using the goto in the script above is having a loop starting at the start: and ending at the goto. So in situations like this it can speed up the code (like it would have in my search engine bot) but if you don't use the goto element in the right places then it can slow your code to pieces.

Now about I mentioned …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Below are 2 options to help solve the problem. Both do the same thing but with different amounts of complexety. My preference is the second code box. And so they are:

$enamysqldb=mysql_connect('localhost','username','password');
mysql_select_db($database_enamysqldb, $enamysqldb);

$coursesubject=mysql_real_escape_string($row_reclog['tablename']);
$query_reclevelsub = "SELECT * FROM $coursesubject";
$reclevelsub = mysql_query($query_reclevelsub,$enamysqldb) or die(mysql_error());

== and ==

mysql_connect('localhost','username','password');
mysql_select_db($database_enamysqldb);

$coursesubject=mysql_real_escape_string($row_reclog['tablename']);
$query_reclevelsub = "SELECT * FROM `".$coursesubject."`";
$reclevelsub = mysql_query($query_reclevelsub) or die(mysql_error());

Remember to replace the words username and password with your real mysql username and your real mysql password.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

What does it say in the address bar? If it says "C:\Program Files\Apache Group\Apache2\cgi-bin\filename.php" then you aren't running it through your server. It is not being parsed as PHP. You have to view it through your server: "http://localhost/filename.php" or "http://127.0.0.1/filename.php" (the same thing).

Just to add to that is it hasn't been made clear, there are two ways the view a file on localhost and one won't load the php code. There is the method of http://localhost/path/to/file/filename.php which in most cases will work then there is the other method of viewing it on the file protocole which can be file://C:\path\to\file\filename.php or C:\path\to\file\filename.php
You need to make sure that you use the method which has the http:// before the path and no C:\ in the path. This way the data request is sent through apachie and php which can then do the server side processing instead of passing that stage. So in short, you need to make sure you use http://localhost/path/to/file/filename.php

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

...
so i need Music player code in php.
...

Well if you are looking for a music player, how can the server play music on the clients computer. Sounds weird trying to get the server to play the music for the client and expect the client to be able to listen to the music. So your best options would be Flash and/or Java. Flash and Java are both client side languages meaning the will load on the users computer and not on the server (I am sure you want to music to load/play on the users computer and not on the server). Then perhaps php can tell Java or Flash where to download the file from. The only other option which I wouldn't recommend is a mixture of Javascript and html. But using Javascript and html it wouldn't look as great as Java or Flash and Javascript is widely disabled.

So those are the options but php itself can't play the music for the client. And after you have chosen one, I would suggest a google search on some client side web scripting tutorials and compilers (if using Java or Flash). Although it may not have been the answer that you wanted I hope it helps solve the problem.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster
@imagejpeg( $tmp_img );

Line 11 in the above quote is incorrect. You first need to get the image then use a separate function to display the image. To make it simple, I have combined them into one line so try replacing line 11 in the above quote with the following

imagejpeg(imagecreatefromjpeg($tmp_img));

Also you may want to check the following link for more info:
http://au.php.net/manual/en/function.imagecreatefromjpeg.php

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Just use the following code. Simple and easy to use.

//set the values
$value_a=9.43;
$value_b=8.20;

//now to calculate
$value=$value_a+$value_b;
$valuesplit=explode('.',$value);
if(!isset($valuesplit[1]))
    {
    $endvalue=$valuesplit[0];
    } else {
    if ($valuesplit[1]>=60)
        {
        $valuesplit[1]='0.'.$valuesplit[1];
        $valuesplit[1]=$valuesplit[1]-0.60;
        $valuesplit[0]+=1;
        $valuesplit[1]=preg_replace('/[^.]+[.](.*)/','$1',$valuesplit[1]);
        }
    $endvalue=$valuesplit[0].'.'.$valuesplit[1];
    }

//now to echo the value
echo $endvalue;
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This is the line that is incorrect (or at least one of them).

$con = mysql_connect("localhost");

Replace it with something like the following but replace the username and password with the real username and real password:

$con = mysql_connect("localhost","username","password");
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have made a script in the past that can store url variables as sessions but I don't know how to SEO (Search Engine Optimization) will go on the header redirect. But anyway, this is how my script works. First, place at the top of all files you want to recieve the hidden values the following code:

<? session_start(); 

if (isset($_SESSION['vars']))
    {
    unset($_SESSION['vars']['url']);
    foreach($_SESSION['vars'] AS $keys => $values)
        {
        $_GET[$keys]=$values;
        }
    }
unset($_SESSION['vars']);
unset($keys);
unset($values);

So in your case, the file leftproducts.php or whatever php file serves product_name.html will contain that code at the very top. Then when linking to a page, you need to link to a different page which forwards the session and $_GET information to the visible page. So while keeping that bit of theory in mind, make a file named linker.php and place the following code in it:

<?
session_start();
if (!empty($_GET))
    {
    unset($_SESSION['vars']);
    $tmp=$_GET;
    $_SESSION['vars']=$tmp;
    }
header('Location: '.$_GET['url']);
?>

Now for the confusing bit, to link to a page with this system. When linking to a page, use the following code:

<?
//url to link to
$url="http://www.mysite.com/shopping/product_name.html";
//hidden id number
$id=2;
//and below is the link
?>
<a href='linker.php?url=<? echo $url; ?>&id=<? echo $id; ?>'>Link Title</a>

Hope that answers your question because yes it is possible.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have read the script and if you are using php5 then the following might be better with the functions file_get_contents and file_put_contents.

<?php
// removal malicious script by forzadraco

$filename="target.php";

$existfile=file_get_contents($filename);

if($existfile){
echo "file berhasil dibaca \n\n";
}else{
echo "file gagal dibaca \n\n";
}


if( false == ($str=file_get_contents( $filename ))) {
echo "Could not read file.";
} else {
echo "File contents: ".htmlspecialchars($str);
}

$hsl=preg_replace("/xxxx/i","draco",$str);

echo "<hr />".htmlspecialchars($hsl);

file_put_contents($hsl,$existfile);

?>

Note: It's good to see you made an attempt at adding the opening code tags but next time try to add the closing code tags too.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

then the images and css file will not came to display...
i think its because of path could be changed...
then how to get them worked..
tel me any idea...

Lets say for example your page is located at www.mysite.com/shopping/leftproducts/1/20
The page will assume your css files are located at
www.mysite.com/shopping/leftproducts/1/20/file.css
And the same applies for images. To pass by this, when adding images, javascript includes, css includes, simply specify the full url. Example:

<img src='http://www.mysite.com/shopping/image.jpg'>
<script src="http://www.mysite.com/shopping/script.js">

And you can see, I have specified the full url and that is so no matter what virtual directory you are in, the browser can still read the external files.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have just resolved a much simular error myself a few minutes ago and turned out the container was not assigned to the variable properly. An example is the following script:

$container_variable = new object();
$container_variable->function();

So that above example is when everything is working. But say the following happened:

$container_variable = new object();
function test() {
$container_variable->function();
}
test();

The above function will not work because the container variable is now isolated in the function where only global variables can be taken into the function. So my point is, this error generally occurs when the container variable is somehow unset or changed. So make sure that the container is a valid object throughout the script.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Also in the past, I have seen this question a few times and a popular answer seems to be Ajax. Although I don't know the first thing about using Ajax, I believe it is ment to be able to read your mysql databases from the client side. From memory lane that is how I think it went but would have to do some research.

And of course there is always the option of putting the menus in iframes so that when one menu is submitted, the individual iframe is reloaded but wouldn't have a good SEO (Search Engine Optimisation).
Hope that helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Just use the file_get_contents() function. Very simple but make sure you place the http:// or https:// before the domain. Below is an example:

<?
$webpage_data=file_get_contents("http://www.google.com/");
echo $webpage_data;
?>
Shanti C commented: smart +3
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
CREATE TABLE `kclove`.`users` (
`userID` INT( 11 ) NOT NULL AUTO_INCREMENT COMMENT 'auto_increment',
`name` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ,
`username` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ,
`password` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ,
`interest` VARCHAR( 255 ) NULL DEFAULT NULL ,
PRIMARY KEY ( `userid` )
) ENGINE = MYISAM CHARACTER SET latin1 COLLATE latin1_swedish_ci

That piece of code does not make sense with the column names userid and userID. If I am not wrong, I believe php and mysql are case sensitive which means that the column name userid or userID will need to be adjusted to the proper casing. And by judging your last error, try replacing all instances of userID with userid. If that doesn't work, make sure you have the right casing by using phpmyadmin.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

My first quesion is regarding the PUBLIC_HTML folder and the use of PHP scripts and MySQL.

Am I correct in saying that any file within the public_html folder is basically open to attackers. For example ...say I have a registration script where members can register on my site.

The register.php file is the actual form that members fill.

The register_proceed.php file is the actual php code that checks, inserts and accesses the MYSQL database.

Well to make a page viewable you will need to appear in public domain meaning if you hide the file from the users, the users will not be able to view or load those files. However there is one alternative. And that is storing all your sensitive php files inside a mysql database so the php code is actually inside a mysql database. Then to read the file, you would need to send the mysql data to the apache/php tmp folder then use the include function on the file in the tmp (not in public_html) folder or something like that. At least that is what I read a while ago.

If i set up a cron job on my server it seems I have to insert the database connection details to allow it to work!

As for the above quote/question, although I don't know much about crone jobs, I believe the same php rules apply meaning that to use mysql, you will need to establish a connection so mysql knows which user is being logged …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Below is the code for the htaccess file:

RewriteEngine On

RewriteRule ^leftproducts/([^-]+)\.html$ leftproducts.php?s_id=$1
RewriteRule ^leftproducts/([^-]+)-([^-]+)\.html$ leftproducts.php?s_id=$1&start=$2

The above code will rewrite the url to the following two urls, first url for the single $_GET variable and second example url below is for when both $_GET variables are in use.
www.something.com/leftproducts/1.html
www.something.com/leftproducts/1-10.html
Notice the two variables are separated by a dash. Hope it helps.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following to match the 2:

$input='bluefox';
$database_input='Blue Fox';

if (str_replace(' ','',strtolower($input))==str_replace(' ','',strtolower($database_input)))
    {
    echo "They match";
    }
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following to match the 2:

$input='bluefox';
$database_input='Blue Fox';

if (str_replace(' ','',strtolower($input))==str_replace(' ','',strtolower($database_input)))
    {
    echo "They match";
    }
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Does Yahoo mail support SMTP?

Yes it does. The settings can be found at http://help.yahoo.com/l/us/yahoo/mail/original/mailplus/pop/pop-14.html

The settings are as follows:

SMTP Server: plus.smtp.mail.yahoo.com 
(Use SSL, port: 465, use authentication)

POP3 Server: plus.pop.mail.yahoo.com (Use SSL, port: 995)

Login username: Your Yahoo! Mail ID 
(your email address without the "@yahoo.com")

Password: Your Yahoo! Mail password

Those are the basic configurations. All it takes is a yahoo web search.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hello,
Please send the coded files to the following email address Uhussain@rediffmail.com, please as have to upload them onto an ftp program to upload to the website. Please help urgently

Thank you

lol. If you want somebody to do the job for you then the are people you can pay for that sort of thing. But if you do wish to receive any help on the forums then you will need to make an attempt to do it yourself first then when errors appear, you then present relevent sections of your code on the forums for advice on how to resolve the coding errors. However, if you ask people to make such a large scale project from scratch that is what I would call getting somebody to do your homework.

So if you think you can't even start by yourself, try doing different project that is a lot easier to get the hang of php then over time with experimentation you will learn more of the functions untill you know enough to make this game. An example of myself trying to go to large scale projects without the basics is my first daniweb post. I asked in the c++ section how to make a program to animate 3D humans and convert the moving people to animations. Never happened because you need to learn the basics first.
So try some tutorials and fiddle around with php untill things for this project seem easier to achieve and that …

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

TommyBs is right. You don't need 's around your field names, and definitely don't use `. Is there in fact a field named status? And try doing this query directly in MySQL (via phpMyAdmin if you have it) and see what error you get.

From my experience, some servers have a compatibility error when not using the apostrophie ( ` ) for some reason. Probably something to the with the apachie config file. But anyways, if you are planning to share your script around, due to this rare compatibility error, it is best to use the apostrophie around column names. Also note the difference between apostrophies and quotations. The apostrophie key can be found at the top left corner of the keyboard beside the number 1 key.

Also when doing an insert query, I generally prefer to use the old fasion technique of column=value. So you can also try the following:

$new = "New to the Site!"
 
mysql_query("INSERT INTO `user_notifications` SET `username`='".mysql_escape_string($username)."', `status`='".mysql_escape_string($new)."'") OR die(mysql_error());

May be very old fashion the way I did it but it seems to do the job (well for me anyway).

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Simply use the explod function to convert the string into an array. So for your example, the following code would apply:

$string="hyderabad,india";
$strings=explode(',',$string);
echo $strings[0]; // outputs: hyderabad
echo "<br>"; // new line
echo $strings[1]; // outputs: india
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The line with the $data= variable needs to be replaced with the following:

$data=file_get_contents('http://localhost/translator/google.translator.php');

And as I mentioned in my previous post, you will need to have two separate files, one for the translator and the other as the file to be translated. Also why don't you try to recompile to example I gave you in my previous post without any modifications. That might be a lot easier as it worked for me.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

by using google api ..
i tried to translate language...
it works but not for the full page only for selected div tag...
plese tell me how to modify or
how i get the full page translated text....body of html or php page

<?
$lang=$_GET['lang'];

?>
<html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">

    google.load("language", "1");

    function initialize() {
      var text = document.getElementById("text").innerHTML;
     // var text = content.document.body;      
google.language.detect(text, function(result) {
        if (!result.error && result.language) {
          google.language.translate(text, result.language, "<?=$lang?>",
                                    function(result) {
            //var translated = document.getElementById("translation");
			var translated = document.getElementById("text");
            if (result.translation) {
              translated.innerHTML = result.translation;
			//text.innerHTML = '';
            }
          });
        }
      });
    }
    google.setOnLoadCallback(initialize);

    </script>
  </head>
  <body>
<a href="xyz.php?lang=hi" title="Hindi" rel="nofollow"><img  src="images/hi.png" alt="Hindi" /></a>
<a href="xyz.php?lang=ar" title="Arabic" rel="nofollow"><img  src="images/ar.png" alt="Arabic" /></a>
<a href="xyz.php?lang=zh-CN" title="Chinese" rel="nofollow"><img  src="images/zh.png" alt="Chinese" /></a>
<a href="xyz.php?lang=nl" title="Dutch" rel="nofollow"><img  src="images/nl.png" alt="Dutch" /></a>
<a href="xyz.php?lang=en" title="English" rel="nofollow"><img  src="images/en.png" alt="English" /></a>
<a href="xyz.php?lang=fi" title="Finnish" rel="nofollow"><img  src="images/fi.png" alt="Finnish" /></a>
<a href="xyz.php?lang=de" title="German" rel="nofollow"><img  src="images/de.png" alt="German" /></a>
<a href="xyz.php?lang=it" title="Italian" rel="nofollow"><img  src="images/it.png" alt="Italian" /></a>
<a href="xyz.php?lang=ko" title="Korean" rel="nofollow"><img  src="images/ko.png" alt="Korean" /></a>
<a href="xyz.php?lang=ru" title="Russian" rel="nofollow"><img  src="images/ru.png" alt="Russian" /></a>
<a href="xyz.php?lang=es" title="Spanish" rel="nofollow"><img  src="images/es.png" alt="Spanish" /></a>
<a href="xyz.php?lang=fr" title="French" rel="nofollow"><img  src="images/fr.png" alt="French" /></a>
   
 <div id="text">Formally, DFS is an uninformed search that progresses by expanding the first child node of the search tree that appears and thus going deeper and deeper until a goal node is found, or until it hits a node that has no children. Then the search backtracks, returning to the most …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Although I'm not the greatest with oop, I did some research and turns out that the function is not an object. That could be one of two reasons. 1 reason is the way the function is defined and the other is what value it returns (not sure about the last one). So try replacing the first line of that last code box with one of the following but other than that I don't have much of a clue.

public function insertseek1($user,$pss)
// or if the above replacement doesn't work try the below in the same line
private function insertseek1($user,$pss)
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Without the line showing how the function is defined it is hard to tell but it looks like you are using a method as a function. A method is an oop thing that can be defined exactly the same way as a function but within a class with a constructor. Although the only oop I do is with php-gtk, I think to use a method you need to call it with its parent like below but with the right variable name:

$parent->insertseek1();

And as I said, I don't know exactly how accurate all of that is but I do believe that it is because you are using an oop method as a function.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I had a try at embeding it in myself and descovered a few bugs but have now fixed them. Also I discovered that for the translator, it can take one or two minutes to translate the entire page. The more html the longer to translate. So there are the following two pages and they must have the names I gave them unless you can alter the code to change their names but the only page visible in the url bar is index.php. To set the up, first place in index.php the following code:

<?
set_time_limit(0);
function translate($textSource, $langSource, $langTarget='')
    {
    if ($langTarget=='') {$langTarget='en';}
    if ($langSource!==$langTarget)
        {
        $textSource=preg_split('/(<|>)/',$textSource);
        $idz=0;
        $openbracket=1;
        while (isset($textSource[$idz]))
        {
        $ch = curl_init();
        curl_setopt_array($ch, array(
        CURLOPT_URL => 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' . urlencode($textSource[$idz]) . '&langpair=' . urlencode($langSource . '|' . $langTarget),
        CURLOPT_RETURNTRANSFER => true
        ));
        $ret = json_decode(curl_exec($ch), true);
        curl_close($ch);
        if ($openbracket==1)
            {
            $bracket='<';
            $openbracket=0;
            $endresult.=$ret['responseData']['translatedText'].$bracket;
            } else {
            $bracket='>';
            $openbracket=1;
            $endresult.=$textSource[$idz].$bracket;
            }
        $idz+=1;
        }
        $endresult=preg_replace('/(.*)\</','$1',$endresult);
        return $endresult;
        } else {
        return $textSource;
        }
    }
if (!isset($_GET['page']))
    {
    $file='default.php';
    } else {
    $file=$_GET['page'];
    }
$data=file_get_contents('http://'.preg_replace('/(.*)\/[^\/]+/','$1/',$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']).$file);
echo translate($data,'en',$_GET['language']);

?>

Then in the same directory as index.php place in default.php the following code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>

</head>

<body>
      <form method='get' style='padding:0px; margin:0px;' action='index.php'>
      <select name='language'>
      <option value='ar'>Arabic
      <option value='bg'>Bulgarian
      <option value='ca'>Catalan
      <option value='zh-CN'>Chinese
      <option value='hr'>Croatian
      <option value='cs'>Czech
      <option value='da'>Danish
      <option value='nl'>Dutch
      <option value='en'>English
      <option value='tl'>Filipino
      <option value='fr'>French
      <option value='de'>German
      <option value='el'>Greek
      <option value='iw'>Hebrew
      <option value='hi'>Hindi
      <option value='id'>Indonesian
      <option value='it'>Italian
      <option …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The mysql query you are looking for looks something like this

mysql_query("SELECT * FROM `tablename` WHERE `column_name`='value'");

If you are new to this then I would strongly suggest following a few tutorials to do things like insert/update/delete data from a database and most importantly to select data from a database. Also while loops you will find very handy for databases. You can find plenty of tutorials at http://www.tizag.com/