nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you sure it isn't working ? This code with slight modification to yours is working.

<?php
session_start();
 $groupname = "test";
echo $groupname;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">

var menu1=new Array()
menu1[0]='<a href="employercp.php">Job Portal</a>'
menu1[1]='<a href="cggroup.php?id=<?php echo $groupname; ?>">Groups</a>'
document.write(menu1[0] + menu1[1]);
</script>

I believe $groupname is empty in your case. :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

Eg.

<html>
<body>
<a href="test.php?id=1">Click here </a>
</body>
</html>
<?php
//test.php
$id = $_REQUEST['id'];
echo $id;
?>

easy ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
$handle = fopen("test.csv", "r"); //open the csv file
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { //get the contents
   $id = $data[0]; //first field is the id
   $string = implode(";",$data); //create a string from the array
   $dataholder[$id] = $string; //assign it to another array keeping id as index
   //echo $string."<br>";
}
fclose($handle); //close the file


$id = 2; //id specified by the user
if(array_key_exists($id,$dataholder)) {  //if that id is in the array that we created
	$value1 = "newvalues34"; //write the new values for that id
	$value2 = "newvalues34";
	$dataholder[$id] = $id.";".$value1.";".$value2; //update the values for that id
	
}

$fp = fopen("test.csv","w"); //open the file for writing.. using w as mode will place the file pointer at the beginning (so everything you had in your file is gone!)
foreach ($dataholder as $line) { //for each element of dataholder array
	$line = $line."\n"; 
   fwrite($fp,$line); //write the values to the file
}
fclose($fp); //close the file

?>

I have written comments wherever necessary. First of all, you get all the contents of the csv file to an array keeping the id as the index.
Then for a specific id, change/update the data and put it back to the array.
Again, open the file in write mode and write the contents of the array to the file.
I agree, this isn't a beautiful solution (Infact, if your system crashes after opening the file in write mode, the original data is lost!). But yep, this is all I could think …

nav33n 472 Purple hazed! Team Colleague Featured Poster

Why don't you start learning php and try it yourself ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
// we must never forget to start the session
session_start(); 
   $dbhost = 'localhost';
   $dbuser = 'root';
   $dbpass = '';
   $dbname = 'urdbname';
   $errorMessage = '';

   if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) 
   {
   
   $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
   mysql_select_db($dbname);

   $userId = $_POST['txtUserId'];
   $password = $_POST['txtPassword'];

   // check if the user id and password combination exist in database
   $sql = "SELECT user_id 
           FROM tbl_auth_user
           WHERE user_id = '$userId' 
                 AND user_password = '$password'";

   $result = mysql_query($sql) 
             or die('Query failed. ' . mysql_error()); 

   if (mysql_num_rows($result) == 1) 
   {
      // the user id and password match, 
      // set the session
      $_SESSION['db_is_logged_in'] = true;

      // after login we move to the main page
      header('Location: main.php');
      exit;
   }
    else
	 {
      $errorMessage = 'Sorry, wrong user id / password';
     }

   mysql_close($conn);
   }
?>

<html>
<head>
<title>Basic Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head> 
<body>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?> 
<form method="post" name="frmLogin" id="frmLogin">
<table width="400" border="1" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="150">User Id</td>
<td><input name="txtUserId" type="text" id="txtUserId"></td>
</tr>
<tr>
<td width="150">Password</td>
<td><input name="txtPassword" type="password" id="txtPassword"></td>
</tr>
<tr>
<td width="150">&nbsp;</td>
<td><input type="image"  name="btnLogin"  value="Login"></td>
</tr>
</table>
</form>
</body>
</html>

Hope this helps, ..
pages based on your requirement...
this code is total in same page.....

One thing I will do on top of this is, sanitize user's input to prevent sql injections. Always use mysql_real_escape_string or addslashes and stripslashes .

nav33n 472 Purple hazed! Team Colleague Featured Poster

What's the error ? Check if the path you have specified in copy is reachable. Also, there are some mistakes.
Its always better to use $_FILES instead of
$_FILES[img1][tmp_name]. Don't give a space between $_FILES and .

nav33n 472 Purple hazed! Team Colleague Featured Poster

Because you are using mysql_fetch_row and trying to use the associated name. Use mysql_fetch_array instead.

Scottmandoo commented: man you help me soo much, thanks. +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

in first page:

<?php

session_start();

$my="blue";
session_unregister("my");
session_register("my");
$_SESSION['my']=$my;
echo "<a href='show_session_var.php'>Click here to go to next page</a>";
?>

in second page:

<?php
session_start();
echo $_SESSION['my'];

?>

You don't have to register a session variable if you are using it. I mean, session_register("my") is not necessary if you are using $_SESSION.
Also, note from php.net

Caution
If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.

source: http://in2.php.net/session_register

nav33n 472 Purple hazed! Team Colleague Featured Poster

First of all, why do you have different name for checkboxes ? You can create a checkbox array by giving the same name for the checkboxes. Then, on page submit, only those checkboxes which were selected will be posted to the next page. I don't know what exactly your script does as I can't figure out what's the relation between users.php and checked.php .

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you are not sure how to use it, refer this thread. http://www.daniweb.com/forums/thread135884-2.html

nav33n 472 Purple hazed! Team Colleague Featured Poster

In your post, it just redirects the user to respective page on button click. It doesn't post the form. In my post, I have specified the action for the form, so it posts the form data to respective script. That is, $_POST will be available in test1.php, test2.php and test3.php on respective button clicks.

nav33n 472 Purple hazed! Team Colleague Featured Poster

you just give different names to your buttons like:

<input type="submit" name="b1">
<input type="submit" name="b2">
<input type="submit" name="b3">

then at the top of your page:
do like this:

<?
ob_start();
if($_POST['b1'])
{
header("location:one.php");
}
if($_POST['b2'])
{
header("location:two.php");
}
if($_POST['b3'])
{
header("location:three.php");
}

That will just redirect the page once the button is clicked. To post the form data to different scripts depending upon the button clicked, you need to make use of javascript.

<html>
<head>
</head>
<body>
<form method="post" name="form">
<input type="text" name="name" />
<input type="submit" name="submit1" value="submit1" onclick="javascript: form.action='test1.php';" />
<input type="submit" name="submit2" value="submit2" onclick="javascript: form.action='test2.php';"/>
<input type="submit" name="submit3" value="submit3" onclick="javascript: form.action='test3.php';" />
</form>
</body>
</html>
nav33n 472 Purple hazed! Team Colleague Featured Poster

This looks good! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I am not sure if you can do that using joins. Join returns all the records which matches the condition. So, there is no way to find out which advertiser belongs to which category.

$query = "select id from category";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
    $categoryid = $row['id'];
  $query2 = "select * from advertisers where category_id='$categoryid' and active=1";
$result2 = mysql_query($query2);
if(mysql_num_rows($result2) > 0 ) {
echo "<h1>".$categoryid."</h1>";
  while($row2 = mysql_fetch_array($result2)) {
$advertisername = $row2['name'];
  echo "Advertiser is ".$advertisername;
}
} else {
 echo "No advertisers found for this category..";
}
}

This way, you can print Category first, then get all the advertisers for that category.

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you post your form to a page, include other php files and process the posted data.
ie.,
page1.php submits to page2.php .
in page2.php, include page3.php and page4.php. So, When you post the form data to page2.php , the same values will be accessible in page3.php and page4.php . Here is an example.

//testpost1.php
<html>
<body>
<form method="post" action="testpost2.php">
Name: <input type="text" name="name">
<br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php
//this is testpost2.php
include "testpost3.php";
print_r($_POST);
?>
<?php
//this is testpost3.php
print_r($_POST);
?>

It will print the form data twice!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Without knowing the flow of your script, none of us can guide you !

nav33n 472 Purple hazed! Team Colleague Featured Poster

$db->query("select 1 from t_counter_tmp where id='$code' and email='$email'");

select 1 from table ? What does it do ? :-/
I don't think it even enters this loop. What does it ( num_rows() ) do ?

if($db->num_rows()) {

My suggestion is to have echo and print_r statements inside every condition. This is an easy way to debug your application.
Eg.

<?php
if($x  == $y ) {
echo "inside if condition..";
// do something
} else {
echo "in else part..";
//do something else
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

I have confirmed it but when followed link to verify confirmation of registry it said nothing is found. Is this a database error.

Umm.. I am not really sure what you mean by that. Can you post relevant part of the code which isn't working for you ? You also have to explain your problem in detail.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Some crazy people screaming their heads off ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Yay!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay.. Don't forget to change it everywhere..

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you are dealing with a string in your query, that is,

$query = "select * from table where name='test'";
$query = "select * from table where date='2008-01-20'";
//...etc

then you are supposed to use single quotes around them.
If you are using an integer, then you don't need those quotes. Eg.

$query = "select * from table where id=3";

So, your query has to be modified a lil bit.

$query = "SELECT * FROM runners WHERE first_name ='".$name."'";

Notice the single quotes around $name. You can also do it this way.

$query = "SELECT * FROM runners WHERE first_name ='$name'";

I hope its clear now.

P.S. Also, since you are using a loop, its always good if you put them in a block. ie., use { } .

while($row = mysql_fetch_array($result)) {
 //something here
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Yap ! Change function name "final" to "finally" or something !

wussa commented: thanks wussa +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

This doesn't help. You need to specify where (which line) you got the parse error and what is the error message.

P.S. My editor and this link says final is a keyword.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Post your code and please use code tags.

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
if(isset($_POST['check'])) {
	$host="localhost";
	$user="";
	$pass="";
	$dbid="upload";
	$link=mysql_connect($host,$user,$pass);
	mysql_select_db($dbid);
	$name = mysql_real_escape_string($_POST['name']);
	$password = mysql_real_escape_string($_POST['apass']);
	$result=mysql_query("select * from login where username='$name' and password='$password'");
	if(mysql_num_rows($result) > 0 ) {
		while($row=mysql_fetch_array($result))
		{
			$type=$row['usertype'];
		}
	}
	if($type==0) {
		header("location: uregister.php");
	} else {
		header("location: userlink.php");
	}
	mysql_close($link);
}
?>
<html>
<head>
<head>
<body>
<form method="post" action="login.php">
<table border=1>
<tr>
<td>
UserName</td><td><input type="text" name="name">

</td>
</tr>
<tr>
<td>
Password</td><td><input type="password" name="apass">
</td>
</tr>
<tr>
<td>
</td><td><input type="Submit" name="check" Value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>

This should work.

praveen_dusari commented: i am learning from u.thank u +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

:-/ Why are you posting the same post thrice when you could have edited it ?


P.S. I don't see mysql_connect and mysql_select_db. It would really help if you post your complete code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Great! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can initialise $start and $limit value. Try the following script. If it works, then, Yay! If it doesn't, then you can post your question in php forum. There are many people who loves to write scripts ! You might get help from any one of them!

<?php
ini_set("max_execution_time", "30000");


# choose a banner

include_once('../includes/db_connect.php');
?>
<?php
ini_set("max_execution_time", "30000");

session_start();

# remove members from the mailing list when they click from within the newsletter
check_admin();

$start = isset($_REQUEST['start']) ? $_REQUEST['start']:"0";
$limit = 10; // how many records you want to show per page

if (isset($HTTP_GET_VARS['mode']) && $HTTP_GET_VARS['mode']=='delete') {
	$id=$HTTP_GET_VARS['id'];
	$query="DELETE FROM dir_site_list WHERE site_id = $id";
	$return=mysql_query($query,$link);
}

$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";
$return=mysql_query($query);
$TOTAL=mysql_num_rows($return);
$sess_id="PHPSESSID=".session_id();
include("$CONST_INCLUDE_ROOT/Templates/maintemplate.header.inc.php");
?>


<?php include('../includes/admin_header.php'); ?>
<?php
while ($sql_array=mysql_fetch_object($return)) {

	$linkback_url="http://$sql_array->site_linkback";
	$linkback_url=trim($linkback_url);

	print("Checking:$sql_array->site_id> <a href='$linkback_url' target='blank'>$linkback_url</a>");
	flush();
	$contents="";

	if (@$fp=fopen($linkback_url,'r')) {
	$chktime=time();
		while(!feof($fp))
		{
		  $contents.= fread($fp,1024);
		  if (time() >= $chktime+3) break;
		}
		fclose($fp);

		if (strstr($contents,$CONST_LINK_ROOT)) {
			$test_result="<font color='green'>Passed</font>";
		} else {
			$test_result="<font color='red'>Failed</font> -> <a href='linkchecker.php?mode=delete&id=$sql_array->site_id&start=$start&limit=$limit'><font color='red'>[Delete]</font></a>";
		}

		print(" -> $test_result<br>");
	} else {
		print(" -> <a href='linkchecker.php?mode=delete&id=$sql_array->site_id&start=$start&limit=$limit'><font color='red'>Failed to open</font></a><br>");
	}

	flush();

}


print("<br>Link Checking Complete");
mysql_close($link);
?>
<p><input type="button" onClick="location.href='linkchecker.php?start=<?php echo $start ?>&limit=<?php echo $limit ?>&<?php echo $sess_id ?>'" value="Refresh" name="btnRefresh">&nbsp;
<input type="button" onClick="location.href='linkchecker.php?start=<?php echo $start+30 ?>&limit=<?php echo $limit ?>&<?php echo $sess_id ?>'" value="Next" name="btnNext"></p>
<p>&nbsp;</p>

<?include("$CONST_INCLUDE_ROOT/Templates/maintemplate.footer.inc.php");?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi all
what is the syntax of the implode fuction how to use it.....in my application

php.net is the source for all php functions my friend. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) You are welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

;) lol..Thats fine with me too! I don't care as long as gremlins satisfy their stomach with my 'virtual reputation' !

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are not supposed to have an echo, any html tag or even a whitespace if you are using header function. You should make sure that no output is sent to the browser before calling header function. You can use ob_start() to start output buffering (and hence avoid this error).

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you are using linux, you can use cron jobs. I don't have much knowledge on it, so you better do some research on the same ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I would rather user php's header function. Thats because, if the user has disabled javascript, javascript redirection fails.

header("location: somepage.php");
nav33n 472 Purple hazed! Team Colleague Featured Poster
  1. Since you want to compare the values in 2 variables, you should use comparison operator. ie., if($a == $b) and not if($a = $b). Thats 1 change.
  2. You shouldn't put single quotes around a variable. If you do, php parser will consider it as a string and not compare the values.
  3. Since the user enters username and password, you can modify your query to have a where clause.

ie.,

$query = "select * from table where username='$username' and password='$password'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0 ) {
//valid user
//proceed with the next step
} else {
//invalid user
} 
  1. You are here for a long time (since Dec 2007). Read guidelines and Use code-tags.

P.S. From next time, mention your problem in detail. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay.. You have some errors in your script.
1.

SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y' ORDER BY site_id LIMIT ,

When you execute the script for the 1st time, no LIMIT is set. That is, $start and $limit will be empty. Thats the reason you are getting the error.
2. There has to be a whitespace between site_live='Y' and ORDER in the query

$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";

3. Since you aren't assigning or calculating $start and $limit, you always get this error.
My suggestion is to ask the person who did this script for you to give you a working pagination script!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. Post the whole page.. I ll tell you what to do next..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Its in the link I have provided. $string = file_get_contents("test.php"); will read the entire file 'test.php' and returns it as a string.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you post your updated code ? echo $query; should print out the query. But anyway, post your complete code.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y' ORDER BY site_id LIMIT $start,$limit"; 
echo $query;

Tell us what it prints.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$string = file('test.php'); // $string is assign for the line of file.

That is where you are going wrong. If you want a string use file_get_contents. file() returns an array.

nav33n 472 Purple hazed! Team Colleague Featured Poster

What exactly are you trying to do with these 2 lines ?

$string = file('test.php');
$strings=processFile($string);

nav33n 472 Purple hazed! Team Colleague Featured Poster

Didn't you post this question already ? Don't double post. Anyway, here is the explanation again.

$string = file('test.php');

file() returns an array.

$strings=processFile($string);

You are passing an array as a parameter to the function processFile.

$lines = file($filename);

In function processFile, you are again trying to open an 'array' (instead of a file). Pass filename as a parameter for processFile function.

nav33n 472 Purple hazed! Team Colleague Featured Poster

change this :
$return=mysql_query($query,$link);

to:
$return=mysql_query($query);

That definitely wouldn't matter. Thats because mysql_query can take an optional parameter of link identifier (the variable used to 'open' the connection).

nav33n 472 Purple hazed! Team Colleague Featured Poster

$string = file('test.php');
$strings=processFile($string);

file() returns an array. So, $string will be an array. You are supposed to send the filename!

nav33n 472 Purple hazed! Team Colleague Featured Poster

The error is because there is something wrong in your query. Print the query, execute it in mysql console or phpmyadmin. (Also post it here) :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi all, We have a "reputation bug" this time. When I view my 'reputation' from my control panel (ie., http://www.daniweb.com/forums/usercp.php) , I see 'up-to-date' reputation (Ref: 1st image). But when I click on "Latest Reputation Received" (http://www.daniweb.com/forums/userrep.php) , I don't see the last received reputation ! (2nd image) :-/ Where did it go ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

need help in php coding !!!!!!!!!!!!!!!
not able to send values to database.................
hav checked the code many times............
when i apply conditions in my code ...it simply stops sending values to database...
plz help.........

Post your code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I tested with IE6 and FF3 and I don't see any difference in the way they work ! I don't have IE5, so I can't really tell where its going wrong(?!?)