nav33n 472 Purple hazed! Team Colleague Featured Poster

Hey, I have an even better idea. Let's put the entire DaniWeb rules into a watermark for the quick reply and advanced reply boxes. That way, no one will break our rules ever again.

Wow! Your idea is undoubtedly better than mine ! ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't think you wrote this script. Did you ? hmm.. Anyway, use this script.

<?PHP
// $Id: ClassJVMemberDisplay.php,v 1.4 2008/03/31 16:55:59 scottcase Exp $

class JVMEMBERDISPLAY
{
	
function menu()
{
	if (isset($id))
	{
		$q=new DB;
		$query="select * from members where id='$id'";
		$q->query($query);
		$q->next_record();
		if ($q->f("paid")==0)
		{
			//$u="";
			$oto=" <a href=\"member.area.oto.php\">Purchase OTO</a> | ";
			$adboxallow="";
			//$u="";
			$oto="";
		}
		else
		{
			$u=" <a href=\"member.area.paid.php\">Download</a> | ";
			$adboxallow="<a href=\"index.php?page=adbox_module\">AdBox Module</a> |";
			$oto="";
		}
	}




	$main="<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" class=box>
      <tr align=\"center\">

<!-- add extra info here at top -->
     <br>
<br>
This is where JV's banners go
<html><!-- Start Code --><iframe src=\"http://www.365netmarketing.co.uk/adds/banner.php?action=b&t=true&ref=20&w=468&h=60&grp=13\" width=\"468\" height=\"60\" marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\" background-color=\"transparent\"></iframe><!-- End Code --></html>



     <br>
<br>
<br>
        <td height=\"20\" class=\"style1\"><span class=\"style3\">
        <a href=\"index.php\">Home</a> |
        <a href=\"index.php?page=profile\">Manage Profile</a> | 
        <a href=\"index.php?page=gift_setup\">Manage Gift</a> | 
        $adboxallow
        <a href=\"index.php?page=promote\">Promote</a> |
        <a href=\"index.php?page=jv_invite\">Invite JV Partners</a> |
        <a href=\"index.php?page=get_gifts\">Get Gifts</a> |
        $u 
        <a href=\"index.php?page=stats\">Referal Stats</a> |
        <a href=\"{helpdeskurl}\" target=_blank>Helpdesk</a> |
        <a href=\"index.php?op=logout\">Logout</a></span></td>
        </tr>
    </table>";
	
	$main=str_replace("{sitename}",$sitename,$main);
	$main=str_replace("{helpdeskurl}",get_setting("helpdeskurl","system"),$main);
	$main=str_replace("{webmasteremail}",$webmasteremail,$main);
	$main=str_replace("{dwld}",$u,$main);
	$main=str_replace("{oto}",$oto,$main);
	
	echo $main;
}

function promote($id)
{
	$q=new DB;
	$currentdate=time();
		$startdate=get_setting("start_date","system");
		if ($currentdate<=$startdate)  { $showform = 0; } else { $showform = 1; }
	$cmember="";
	//$cmember=get_template('template_jv_home_htm');
	FFileRead("templates/jv/template.jv.promotion.tools.htm",$cmember);
	$cmember=str_replace("{buzz_email1_subject}",get_setting("buzz_email1_subject","promotion"),$cmember);
	$cmember=str_replace("{buzz_email1}",get_setting("buzz_email1","promotion"),$cmember);
	$cmember=str_replace("{buzz_email2_subject}",get_setting("buzz_email2_subject","promotion"),$cmember);
	$cmember=str_replace("{buzz_email2}",get_setting("buzz_email2","promotion"),$cmember);
	$cmember=str_replace("{promo_email1_subject}",get_setting("promo_email1_subject","promotion"),$cmember);
	$cmember=str_replace("{promo_email1}",get_setting("promo_email1","promotion"),$cmember);
	$cmember=str_replace("{promo_email2_subject}",get_setting("promo_email2_subject","promotion"),$cmember);
	$cmember=str_replace("{promo_email2}",get_setting("promo_email2","promotion"),$cmember);
	$cmember=str_replace("{promo_email3_subject}",get_setting("promo_email3_subject","promotion"),$cmember);
	$cmember=str_replace("{promo_email3}",get_setting("promo_email3","promotion"),$cmember);
	$cmember=str_replace("{promo_email4_subject}",get_setting("promo_email4_subject","promotion"),$cmember);
	$cmember=str_replace("{promo_email4}",get_setting("promo_email4","promotion"),$cmember);
	$cmember=str_replace("{promo_email5_subject}",get_setting("promo_email5_subject","promotion"),$cmember);
	$cmember=str_replace("{promo_email5}",get_setting("promo_email5","promotion"),$cmember);
	
	$cmember=str_replace("{id}",$id,$cmember);
	
$theform = NULL;

$notyet = "<p align=\"center\"><b>&nbsp;</b></p>
<hr>
<p align=\"center\"><span style=\"font-weight: 700; background-color: #FFFF00\">
<font size=\"6\">Promotion Has Not Started Yet.</font></span></p>
<p align=\"center\"><span style=\"font-weight: 700; background-color: #FFFF00\">
<font size=\"6\">You can invite JV Partners Now.</font></span></p>
<hr>
<p align=\"center\">&nbsp;</p>";


if ($showform) 
{
$cmember=str_replace("{sform}",$theform,$cmember);
}
else
{
$cmember=str_replace("{sform}",$notyet,$cmember); …
nav33n 472 Purple hazed! Team Colleague Featured Poster

$main="<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" class=box>
<tr align=\"center\">

<!-- add extra info here at top -->
<br>
<br>
This is where JV's banners go
<html><!-- Start Code --><iframe src="http://www.365netmarketing.co.uk/adds/banner.php?action=b&t=true&ref=20&w=468&h=60&grp=13" width="468" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowtransparency="true" background-color="transparent"></iframe><!-- End Code --></html>

If you open your script in any good editor, you will see the problem yourself.
You have to escape " in this line.

<html><!-- Start Code --><iframe src="http://www.365netmarketing.co.uk/adds/banner.php?action=b&t=true&ref=20&w=468&h=60&grp=13" width="468" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowtransparency="true" background-color="transparent"></iframe><!-- End Code --></html>

nav33n 472 Purple hazed! Team Colleague Featured Poster

:S hmm..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm..Then you should post your question in javascript forum..

nav33n 472 Purple hazed! Team Colleague Featured Poster

I guess the error has something to do with the script browsercheck.php because I don't see anything strange on line 49 of this script.

nav33n 472 Purple hazed! Team Colleague Featured Poster

How about "Please no leet speak" along with

Read me first
wrap code in [code ] [/code ]
Use [code=language ] [/code ]
.....
.......

(in 'post quick reply box' and 'Advance reply box') ?

P.S. Another guest got thrashed for the same (da,kewl,...) here

nav33n 472 Purple hazed! Team Colleague Featured Poster

I am doing great! Thanks..

could I set a variable to get the current date, then use explode (I have no knowledge of this function yet, could you give me an example of it?) to extract the month, and then pass that into the SQL query, so it would always be selecting the current month?

You can simply use, $month = date("m"); to get the current month.
Well, If you want to get the stories for each month, then yep, you have to 'talk to the database' 12 times.
You can use a loop and write a query in that loop.

for($i=1;$i<13;$i++) {
$query = "select * from table where month(datecolumn)='$i'";
//do something
}

If you want to select all the records, you can do it that way too. But then, you have to do alot of processing to do.

$query = "select * from table";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
 $datefield = $row['datecolumn'];
//say date is stored as 24-06-2008
list($date,$month,$year) = explode("-",$datefield);
if($month == "06") { //or whatever month
//do something
}
}

Well, its upto you to decide which one is better. I would prefer the 1st method though.
P.S. I have shown the working of explode too!

nav33n 472 Purple hazed! Team Colleague Featured Poster

and I need to pass the variable "1stOtherStuff" (which is an element in an array) to a PHP script, how do I do that?

Have an onchange event for select tag. Submit the page in onchange event. When the form is submitted, you can access the value of the 1stOtherStuff this way. $select_value = $_REQUEST['1stOtherStuff']; Here is a simple example.

<?php
$selected_value = $_REQUEST['select'];
echo "Selected value is ". $selected_value;
?>
<html>
<body>
<form name="form1" method="post" action="onchange.php">
<select name="select" onchange="javascript: document.form1.submit();">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
<input type="button" name="button" value="Click me too!">
</form>
</body>
</html>

If you don't use onchange event, then you can use a submit button. When the button is clicked, the value of select tag is passed to the calling script.

<?php
if(isset($_REQUEST['submit'])) {
$selected_value = $_REQUEST['select'];
echo "Selected value is ". $selected_value;
}
?>
<html>
<body>
<form name="form1" method="post" action="onchange.php">
<select name="select">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

If you still have any doubts, let us know :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

$checkbox = $_POST;
$result = mysql_query("select * from register where checkbox =('$checkbox')");

You can't do it this way. $checkbox is an array and your query will not return any rows.
You have to go through each element of the array (ie., $checkbox) and then use it in your query.
And I don't know what a datagrid is.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, Your structure is good.. You can use month function to get the month.

select * from table where month(datecolumn)="06"

If you want to narrow your search and get both year and month,

select * from table where year(datecolumn)="2008" and month(datecolumn)="06";

And, date is a keyword. Its better not to use date as a column name. If you use it, you have to refer the column as `date` in your queries. :)
Cheers,
Nav

Edit: If you don't want to separate it in mysql, you can also do it in php. You can use explode function (if you are storing the date in a different format) or date function.
You are absolutely right about getting the latest 5 stories. But a small change though. It should be desc instead of asc.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you sure it isn't working ? Well, I have this code and it works. Oh, btw, I removed unwanted ?> and <?php .

//test.php
<!-- add extra info here at top -->
     <br>
<br>
This is where JV's banners go
<html>
<!-- Start Code -->
<iframe src="http://www.365netmarketing.co.uk/adds/banner.php?action=b&t=true&ref=20&w=468&h=60&grp=13" width="468" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" allowtransparency="true" background-color="transparent"></iframe>
<!-- End Code -->
</html>

See the attached image for the screenshot !

nav33n 472 Purple hazed! Team Colleague Featured Poster

There is something wrong with this url.

http://www.365netmarketing.co.uk/adds/banner.php?action=b&t=true&ref=20&w=468&h=60&grp=13

It seems like you have a loop which never ends!
And, you can have html in a php file.

<html>
<body>
Test
</body>
</html>

You can call that test.php .. So, I think the problem is with your php script, banner.php .

nav33n 472 Purple hazed! Team Colleague Featured Poster

As Luckychap has mentioned, validations should be done in the function formCheck. If you have an action specified (eg. action="test.php"), it will then go to the test.php if formCheck returns true. If the function returns false, it will remain in the same page.

nav33n 472 Purple hazed! Team Colleague Featured Poster
mysql_query("delete from job where jobtite='$jtitle'") or die("error");
nav33n 472 Purple hazed! Team Colleague Featured Poster

nevermind.

nav33n 472 Purple hazed! Team Colleague Featured Poster

How can you differentiate users ? I think you need 2 separate queries. One query to get all the user ids and in the while loop, have another query to calculate the time.

$query = "select distinct(userid) from table"; //query to each user's id
$result = mysql_query($query);

while($row  = mysql_fetch_array($result)) {
  $id = $row['userid'];
$total = 0;
 $query2 = "select * from table where userid = '$id'"; //query to get the relevant records of this user
$result2 = mysql_query($query2);
while($row2 = mysql_fetch_array($result2)) {
//display the records as you are doing now
//also calculate the total_time in this loop
$total = $total + $time; 
} //by the end of this loop, you will have $total (total time) for that particular user
echo "total : ".$total;
} //process next user

You can do it this way :)

kvdd commented: Again he did the job, in the topic: "Show a total in a while". Thanks! +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Write what you have in delete.php in index.php under certain condition. I am sure you are passing some value to delete.php to delete the record. For example, <a href="delete.php?id=$xyz">delete</a> You can check in index.php if $_REQUEST is set.
ie., in index.php

if(isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
  //execute the query to delete the record for this particular id
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

It would be much better if you post your complete code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't understand what you mean by your title.. :) Can you be more specific ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. I guess you didn't read my post.. Wrap your code in code-tags.. AND

mysql_close($link);
mysql_query("update job set jobtite = '$jtitle'");

nav33n 472 Purple hazed! Team Colleague Featured Poster

mysql_close($link) before the update query.

Btw, You don't have a condition for your update query. This will update all the records in the table and set jobtite to the value that you have entered.

P.S. Next time, please wrap your codes within code-tags.

nav33n 472 Purple hazed! Team Colleague Featured Poster

This explains many options for submit buttons
http://www.cs.tut.fi/~jkorpela/forms/imagebutton.html

:'( I am lil too late to reply !

nav33n 472 Purple hazed! Team Colleague Featured Poster
<html>
<head>
<script type="text/javascript">
function showmsg() {
	alert("welcome!");
}
</script>
</head>
<body>
<input type="image" src="calendar.jpg" onclick="javascript: showmsg();" />
</body>
</html>

Like this..

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't think inserting and displaying would cause the problem! But anyway, problem fixed ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Strange! Does it have something to do with file extension ? :S

nav33n 472 Purple hazed! Team Colleague Featured Poster

And, mysql_fetch_row returns numeric indexes. Use, mysql_fetch_array or mysql_fetch_assoc instead.

P.S: Plz make it fast isn't the right way to post a thread in the forum :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Convert the time into minutes(or seconds), add them in the loop, display it converting it back to the way you want !

nav33n 472 Purple hazed! Team Colleague Featured Poster

1. You don't have session_start
2. Since you have while loop,

while($row = mysql_fetch_array($result) && $counter < 1)
{
$counter++;
First Name:<?php echo $row; ?> <br>
Last Name:<?php echo $row; ?> <br>
Address:<?php echo $row; ?> <br>
E-Mail:<?php echo $row; ?> <br>
Gender:<?php echo $row; ?> <br>
User Name:<?php echo $row; ?>
}

This part of the code will not work.
Try this.

<?php
session_start();
include("auth_user.inc.php"); // authrization page
$uname=$_SESSION['user']; // logged user name
$connection=mysql_connect("localhost","root"," ");
mysql_select_db("userrecord",$connection);
$sql=("select * from table_user where uname ='$uname'");
$result=@mysql_query($sql,$connection);

?>
<html>
<head><title>User Account</title>
</head>
<body bgcolor="#33CCFF">
<br>Your Details Information Is Shown Below:<br><br>
<?
$counter = 0;
while($row = mysql_fetch_array($result) && $counter < 1)
{
        $counter++;
        echo "First Name: ". $row['fname'] ."<br>";
        //.. and so on...
	
}
?>
</body>
</html>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. Do you have enctype in the form ? Are you sure image is getting posted ? Check for permissions of the destination directory. Remove @ before move_uploaded_file, as @ supress any error message.

Edit: Btw, many of your if and else { are not closed. Have you disabled error reporting ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

What error message ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Lol.. Walking heart attack ! 100%.. I wish I could do this in real life without getting fired ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. this is a logical solution and I don't think a website has an example.
Eg of what I was talking about.

<?php
if(isset($_REQUEST['ajax']) && $_REQUEST['ajax']=="true") {
   echo "Executing ajax function.. ";
//implementing this script with your existing script
} else {
echo "Your actual script !";
//original script 
}
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. Its possible to send many variables to the function (as long as you have defined it in the function).
You can put gethint.php in your script by putting everything in a condition. That is, for example, set a variable &ajax=true. In your phpscript, check if $_GET is set and its true. If yes, execute this part of the code, else, continue with normal execution of the script.
echo the 'confirmation part' after you execute the query. (Just like how we are echo-ing the query here).
I am learning ajax ! So, its not my strong area yet ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ah! you need to use a while loop for that.

while($row = mysql_fetch_array($result)) {
 echo $row['columnname'];
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

I can see you are setting it via url. But you are not assigning the value to $id, but $bw. So, none of your queries will work (unless you have register globals turned on!)
Can you be more specific ? Are you getting any error ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

1. What if $result3 returns more than 1 row ? It will never enter the condition elseif(mysql_num_rows($result3) == 1) 2. $bw = $_GET;
and $id is empty.

nav33n 472 Purple hazed! Team Colleague Featured Poster

What is the error ?
$pimage is null ! If you want the image name to be inserted to the table, you should insert $_FILES.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't think I ever seen mysql_fetch_array used without some type of loop.

You can. It will fetch only the 1st record.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Remove @ before mysql_query. Use die(mysql_error()); ie., mysql_query($sql) or die (mysql_error());

nav33n 472 Purple hazed! Team Colleague Featured Poster

But she says it there are records but no data in it ! :S really strange!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Eureka!!

We knocked the '' off!

Finally got it in to my dense head I needed to use a common field between the two tables
namely 'artist_id'. I'd worked out by counting that the number of visits by Maori had been a number under 40. I got 35 and hit the roof, better than you know what.

$sql = "SELECT * FROM artists_details LEFT JOIN attendance ON attendance.record_id AND attendance.visit_date >= '".$from_date."' AND attendance.visit_date <= '".$to_date."' WHERE artists_details.ethnicity='maori' AND attendance.artist_id=artists_details.artist_id";
echo $sql;
$result=mysql_query($sql);
$num_rows_m = mysql_num_rows($result);

Thanks guys for all your help and interest,
Happy day Harrence.

Bingo! Thats what I was talking about ! :) Congrats !

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) you are welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

ah! I see.. So, did it fix the problem or are you still facing some kinda problem ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Few questions..
1. Why are you using sessions before authenticating the user ?
2. Why are you having 2 different queries for checking a valid user ?
3. order by user_name ? You don't need that actually !
And mysql_fetch_array's syntax is
mysql_fetch_array(result, result_type);
result_type = MYSQL_ASSOC or MYSQL_NUM.

$_SESSION==1;

== is a comparison operator, you should use = .
Isn't this a complete reduced version of your code ?

<?php
session_start();

include 'config.php'; //contains $hostname,$username,$password

$connect=mysql_connect($hostname, $username, $password); //connect 
mysql_select_db("worldofp_blog1") or die(mysql_error()); //select db

/* sanitize user's input  */
$user = mysql_real_escape_string($_POST['user']); 
$pass = mysql_real_escape_string($_POST['pass']);


$get="SELECT user_name, pass_word from user where user_name='$user' and pass_word='$pass'"; //check if username and password exists
$result=mysql_query($get) or die(mysql_error());
$is_valid = mysql_num_rows ($result);

if($is_valid) { // if a record exist set $_SESSION['authuser1'] = 1
	echo "hello";
	$_SESSION['authuser1']=1; 
} else { //else set $_SESSION['authuser1'] = 0
	echo "no";
	$_SESSION['authuser1']=0;
}
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Read http://in2.php.net/types.string

You have to either escape " or use '.
Eg. echo "this will "throw" an error"; The above sentence will cause an error. When it encounters " before throw, it will consider it the end of the statement.
So, instead, you can use, echo "this will 'throw' an error"; or echo "this will \"throw\" an error"; I hope thats clear. I also think now you can now solve your problem ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. It will surely work on Linux.. I don't have linux, so, I can't really test it. But, chdir works independent of the OS you are using.

nav33n 472 Purple hazed! Team Colleague Featured Poster

you could try:

str_replace("	", "\t",$string);

I think that doesn't work.. :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can also use <pre> tag.
http://www.w3schools.com/TAGS/tag_pre.asp

<?php
mysql_connect("localhost","root");
mysql_select_db("test");
if(isset($_POST['submit'])) {
	mysql_query("insert into tst (name) values ('".$_POST['tarea']."')");
}
?>
<html>
<body>
<form method="post">
<textarea name="tarea" cols="30" rows="20"></textarea>
<input type='submit' name="submit" value="submit">
</form>
</body>
</html>
<?php
$q = "select * from tst";
$r = mysql_query($q);
if(mysql_num_rows($r) > 0 ) {
while($row = mysql_fetch_array($r)) {
	echo "<pre>";
	echo $row['name'];
	echo "</pre>";
	echo "<br>";
}
}
?>

Just did a quick check to see if it works and it does..