nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay! So.. When I checked the source of the script, there was only name and not the path.. You have to give the path to your images.. Secondly, You don't have to give the whole path, ie.,

$img_src="C:/wamp/www/prawin/new/locations/test/upload/image/";

Since you are executing the script from http://localhost, this should work just fine.

$img_src="prawin/new/locations/test/upload/image/";

Lastly, you have to concat $img_src to $filename to get the path of the image.

echo '<img src="'.$img_src.$filename.'"/>';

And please indent your code. Indentation is very helpful when you have more than 2 lines of code. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Post your code in code tags. Not everything! Before you click 'Submit' click on 'Preview' button. See if it is readable. If it is readable, then click on submit. :confused:

nav33n 472 Purple hazed! Team Colleague Featured Poster

Edit your post. Use [code] tags to wrap your code for better readability (and better response).

nav33n 472 Purple hazed! Team Colleague Featured Poster

If the string is in this format

aaaaaaaaaabbbbbbbbbbcccccmail@yahoo.comdddddddeeeeeeeffff

I don't think you can extract the email address, since you wouldn't know what is the exact part before @. If your string is as you stated above, ie.,

ssfihuihuiifhhdfhishfihfh jjjjjif ee@gg.com jfiosofjojofjjm ojofjojfc ojjofjojw

then you can explode the string to an array, then check each array element (with regular expression), if it contains a valid email address.

nav33n 472 Purple hazed! Team Colleague Featured Poster

@Kevin wood, Your script seems fine.
Try this.

$query = "SELECT email FROM emails";
	$result = mysql_query($query) or die(mysql_error());

	while($row = mysql_fetch_array($result)) {
	
	$emailaddress[] = $row['email'];
	}


	// Contacts
	//$replyName = $merc_replyId;
	//$replyEmail = $merc_replyAddress;
	$i=0;
	foreach($emailaddress as $contactemail) {
	$replyName = "PiPonliine";
	$replyEmail = "info@piponline.info";

	$contactname = "";
	

	// Subject
	$subject = "Website Update";

	// Headers
	$headers = "MIME-Version: 1.0" . PHP_EOL;
	$headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL;
	$headers .= "From: ".$replyName." <".$replyEmail.">" . PHP_EOL;
	$headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL;
	

	mail($contactemail, $subject, $message, $headers);
	$i++;
	}
  echo "$contactemail"; //this will print only 1 email address, which is the last one
  echo "<h2>Email notification sent</h2>";
  echo "<h2>".$i." mails sent</h2>";

This definitely works. (I tried with 3 email addresses)

kevin wood commented: very helpfull +2
nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep! You are right.. Notices are important. They make you a better programmer :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

The way you are doing it is wrong.
Try this.

$qa = mysql_query("SELECT DATE(DATE_SUB(now() , INTERVAL 31 DAY))  as actual_date");
while ($row = mysql_fetch_array($qa)) { 
	$a = $row[actual_date]; 
}
$qb = mysql_query("SELECT CURDATE();");
while ($row = mysql_fetch_array($qb)) { 
	$b = $row[0]; 
}
mysql_query("SELECT * from $vtable WHERE (trxdate >= '$a') and (trxdate <= '$b') " );
nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of creating a comma separated string, why don't you use foreach loop ? You can get the key as well as the value. Use the 'key' as variable name!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Here are my 2 cents. You can disable those notices by using error_reporting(E_ALL ^ E_NOTICE); on top of your script. If you don't want to disable it but still want to fix the notices, initialize a variable to 0 (or null if its a string). ie.,
$i = 0;
$string = "";
That would fix the error(Notice).
You can learn more on error reporting here. http://in2.php.net/error_reporting

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
/** 
*.Hack Name:        Shop Hack 
* Version:          3.0 Beta2 * 
* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
* **/
define('X_SCRIPT', 'install.php'); 
// Get required files    
if ( !is_file('./include/shop.inc.php') ) {        
exit('Missing file: /include/shop.inc.php');    
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

My idea is also that , if we learn technology contribute it to , and
even use it only for the good things ( not like to build mass killing machines ) only , then why the ppl hates a good person just for he is still single ?

Are you psychologically depressed ? What is all this fuss about being single or married ? Why are you so obsessed with technology ?

Technology makes the life easy ! and if that is your hobby then what is the point of the marriage ? Is there is a rule that everybody should married ? someone smart in marriage life and some are not.

Technology definitely make life easy. Technology can be a hobby, but marriage can never be a hobby! (oh, for some, it is).

I think if somebody use the technology and do only the good things then there is no reason to ppl to hate me.

Why does someone hate you for using the technology ? :S

Believe me I'm nothing much smart in C++ , and as like other students I also need a job, I apply for a job via a friend's relation and my frirst assignment is to program a dirty adult site using PHP.

A client is a client and an assignment is an assignment. You are asked to write scripts, not enact !

But ppl still hating me just because I'm single . I cannot underestand the ppl's behaviour.

And I can't …

nav33n 472 Purple hazed! Team Colleague Featured Poster

I found webman07 getting beat up by Trudge and then backed up by Nav33.....sigh.

:D What are you saying man ? Backed up ? I wasn't even trying to be mean there!

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Nevermind! To decipher that 'string', you should atleast be in 3rd grade.

nav33n 472 Purple hazed! Team Colleague Featured Poster

hii
i m designing a php event based calendar
this is my code, can anyone tell me its script code,mine is not working..

<!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" />
<title>Untitled Document</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
// Get values from query string
$day = $_GET["day"];
$month = $_GET["month"];
$year = $_GET["year"];
$sel = $_GET["sel"];
$what = $_GET["what"];

if($day == "")
$day = date("j");

if($month == "")
$month = date("m");

if($year == "")
$year = date("Y");
$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
$numEventsThisMonth = 0;
$hasEvent = false;
$todaysEvents = "";

<table width='350' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class='head' width='50'>S</td>
<td class='head' width='50'>M</td>
<td class='head' width='50'>T</td>
<td class='head' width='50'>W</td>
<td class='head' width='50'>T</td>
<td class='head' width='50'>F</td>
<td class='head' width='50'>S</td>
</tr>

$numDays = date("t", $currentTimeStamp);
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");

if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);

for($j = 0; $j < $firstDay; $j++, $counter++)
echo "<td>&nbsp;</td>";
}

if($counter % 7 == 0)
echo "</tr><tr>";

echo "<td width='50'>$I</td>";

if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Not only the tmp folder, but also php-ses folder. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

*Repeats*
Its not the 'invisible character' in your script that is causing this error. Its the permissions. Change the permission of the folder php-ses and tmp to 0766. Ie., Read, write and execute to the owner
Read, write to groups and others. :) It will fix the problem. If you can't do that yourself, ask your system admin to do it for you.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yeah.. In some applications, I had to connect to the supplier database and consumer database to show the supplier - consumer information.. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

We don't have any special method of determining "member of the month". And no, it's not 'fair'. Basically anyone who's known in the community is eligible, and in the end happygeek just picks someone who he thinks will make an interesting interview for the next month's newsletter.

Now, that makes sense.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You got it wrong. It doesn't perform the query after the connection is closed. In the above example, it queries the table, closes the connection and then uses the result resource.
And yes, mysql_close also don't need $link_identifier.
As cwarn23 has mentioned already, if you are having multiple database connections in your script, then you need to mention $link_identifier to specify which database's table you want to query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ya I was using the die function but it was causing me problems but if you have multiple die statements then :p, which you would have seen in the previous threads.

;) Then, you will fix the errors one by one !

My error reporting is as follows, after reading the comments it seems this is the best anyways "error_reporting = E_ALL & ~E_NOTICE"

Yep! In my opinion, that is the best option of error reporting. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep.. It doesn't.. mysql_fetch_array doesn't connect to the database. It just uses the result resource returned by mysql_query (which uses $link_identifier).
See this for example.

<?php
$con = mysql_connect("localhost","root");
mysql_select_db("test");
$query = "select * from test";
$result = mysql_query($query);
mysql_close($con);
while($row = mysql_fetch_array($result)) {
	print "<pre>";
	print_r($row);
	print "</pre>";
}
?>

Even though I have closed the connection before mysql_fetch_array, it still works.
Since its an optional parameter, I don't use it (big project or small).

nav33n 472 Purple hazed! Team Colleague Featured Poster

http://in2.php.net/manual/en/ref.mysql.php Most of the functions which interacts with the database can have this $link_identifier as an optional parameter.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you use die function and if an error occurs and prints the die message, then its pretty obvious where exactly the error has occurred !
For runtime errors, php parser will only let you know where the error has occurred if you have error_reporting turned on.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You cannot access $_POST in action2.php . Its only available in action.php since it is posted from form.php to action.php . In order to make it available in action2.php (which is a hyperlink), you have to pass it in the query string like this.

echo "<a href=action2.php?startdate=".$_POST['startdate'].">Click here to go to action2.php </a>";
//You can then access startdate in action2.php as $_GET['startdate']

If you don't want to pass it in the query string, you can use sessions (But I think using sessions only for this particular variable is useless).

nav33n 472 Purple hazed! Team Colleague Featured Poster

Apart from that, If you are sure that the 'input' is an integer, you can validate it using is_numeric .

nav33n 472 Purple hazed! Team Colleague Featured Poster

Someone posted a question in mysql forum which almost resembles this one!
http://www.daniweb.com/forums/thread179456.html Modify those queries and it should work for you!

nav33n 472 Purple hazed! Team Colleague Featured Poster
select * from table order by datecolumn desc

Will work fine. How does php consider this as a math problem ? What is the query you are using ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
header("location: index.php?variable1=".$variable1."&variable2=".$variable2);

:)

OmniX commented: Thanks as always nav ;) +2
nav33n 472 Purple hazed! Team Colleague Featured Poster
<form method='post' onsubmit='javascript:validateform(this);'>

It doesn't really matter whatever view it is.

nav33n 472 Purple hazed! Team Colleague Featured Poster

There are 3 people already on this page! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Explode the textbox value. Then use the exploded values to
1. build your query this way.

where title like '%PHP%' or title like '%ASP%' or title like '%developer%' or title like '%programmer%' or title like '%web developer%' or title like '%Java%'

2. Or you can have different queries for every exploded value.

select * from table where title like %PHP%';
select * from table where title like '%ASP%';
....etc...

I can't think of anything else. Maybe someone else has a better idea.

nav33n 472 Purple hazed! Team Colleague Featured Poster

But im just wondering if I can do the same thing using headers header("Location: index.php?variable=1")

Yes you can. Then you can acess the 'variable' in index.php just like how you do it using $_GET.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Good point. Maybe Happygeek can explain the terms (for the selection of Member of the month) better.

$surprised++;

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you sure your query returns ASP developer/WEB developer/PHP when you use LIKE '%PHP developer%' :S This, infact should return only "PHP developer".

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool ! You too..

nav33n 472 Purple hazed! Team Colleague Featured Poster

We all learn from our mistakes! Don't we ? :) I am good. Thanks! I hope you are doing great too. Cheers man!

nav33n 472 Purple hazed! Team Colleague Featured Poster

table = mysql reserve keyword.

Use `table` instead.

kevin wood commented: always very helpfull and gives good answers +2
nav33n 472 Purple hazed! Team Colleague Featured Poster

I would suggest using curl to tap into another websites currency converter. Let me know if you would like an example as it would be kinda hard to make.

I would surely love to see one..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome back (I don't know you though). Could you explain what exactly are you looking for ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Php is very easy to learn. You can start by going through these pages.
http://www.w3schools.com/php/php_intro.asp
You can also find how php and mysql interacts on this link.
http://www.w3schools.com/php/php_mysql_intro.asp
One suggestion. Saving images in the database is not a good idea. You can save the image on the server and save its file location in the table.
All the best with your application! Happy learning.. If you face any problem, you can always come here.

Cheers,
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Cool!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Darn! I typed a long paragraph and just before I clicked 'Post' I lost my internet connection.
Does it still say No database selected ? You only get "No database selected" if you don't have mysql_select_db or if you have specified wrong database name. :)
Anyways, Try using another database to see if that works. If it doesn't work, then you have to contact your system admin :S
Sorry. I don't have any guide w.r.t site search engine. Well, maybe someone else from this forum can help you with it.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you want to count the number of records in the table, you can use mysql_num_rows.

$query = "select * from tablename";
$result = mysql_query($query);
echo mysql_num_rows($result)." records found...";

If you want the number of columns in a particular table,

$query = "show columns from tablename";
$result = mysql_query($query);
echo mysql_num_rows($result)." columns ...";

As in the above example, once you find out the total rows, you can split it into 2 (or put it in 2 separate arrays and use it wherever you want!).

nav33n 472 Purple hazed! Team Colleague Featured Poster

$result will have a result resource. You need a loop to get all the result. mysql_fetch_array() will fetch only 1 record at a time.

while($row = mysql_fetch_array($result,MYSQL_NUM)) {
print "<pre>";
 print_r($row);
print "</pre>";
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Ah! How could we miss that in your first post :icon_surprised:
Even after specifying the database, it said "sorry database not connected No database selected" ? Hmm.. Strange..
Try this.. The 2nd parameter is optional, but, lets see if this can do the trick. $dbselector = mysql_select_db('lsschnln01',$dbcnx); If it still says no database selected, then :icon_confused: you better check if the database really exist.

P.S. Never give out your database username/password in a forum.

nav33n 472 Purple hazed! Team Colleague Featured Poster

So we got two solutions to one problem. Thats what I call a good days work.
(pfiuuh.. its been 36 hours since sleep so I'm outta here, thanks for a nice quiz/problem. It will come in handy for sure.)

Yeah.. 1 solution, good. 2 solutions, better :)

Get some sleep dude! Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

@Dickersonka, I have been advised on so many occasions not to use joins. Joins are relatively slower compared to subqueries. This is what I have read.

nav33n 472 Purple hazed! Team Colleague Featured Poster

YAAAA... Knew it would be doable with a subquery...
I just tested this...

select `fn`,`ln`, (select count(`orderid`) from `order` where `client`.`username`=`order`.`username`) AS `xcnt` FROM `client`
 WHERE `client`.`active`='1'
 GROUP BY `username`;

It returns a count of orders per client and sets the xcnt = 0 where no orders occurred, but shows first name and last name per client
who is active in the system

Subqueries are even better.. :)

select `user_id`, (select count(`comment`) from `comments_table` where `comments_table`.`user_id`=`users_table`.`user_id`) AS `xcnt` FROM `users_table`
 GROUP BY `user_id`;

I edited your query and it works ! Eureka ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I modified your query a little bit and I don't know why it doesn't return users who have post = 0.

SELECT COUNT(
COMMENT ) AS `post_count` , (

SELECT `user_id`
FROM `users_table` u
WHERE `comments_table`.`user_id` = `u`.`user_id`
) AS `ugrp`
FROM `comments_table`
GROUP BY `ugrp`
ORDER BY `post_count` DESC
LIMIT 0 , 30;

Another query.

SELECT u.user_id, count( * ) AS post_count
FROM users_table u, comments_table p
WHERE u.user_id = p.user_id
GROUP BY u.user_id
LIMIT 0 , 30

Both returns the same result.


Edit: @Dickersonka, Your query works like a charm! Great job! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Nice queries.. But still, that wouldn't solve what OP is looking for.. The still doesn't return the count as 0, if a user doesn't have any posts. I created dummy tables to create the same scenario and I am also clueless ! :S