nav33n 472 Purple hazed! Team Colleague Featured Poster

What error do you get ?
And what do you have this for ?

if($ufile !=none)
{
......
}

This works for me :)

<?php
//set where you want to store files
//in this example we keep file in folder upload 
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "./images/".$_FILES['ufile']['name'];
if(isset($_POST['Submit']))
{
if(copy($_FILES['ufile']['tmp_name'], $path)) 
{
echo "Successful<BR/>"; 

//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$_FILES['ufile']['name']."<BR/>"; 
echo "File Size :".$_FILES['ufile']['size']."<BR/>"; 
echo "File Type :".$_FILES['ufile']['type']."<BR/>"; 
echo "<img src=\"$path\" width=\"150\" height=\"150\">";
}
else
{
echo "Error";
}
}
?>

<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="upload_file.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>Single File Upload </strong></td>
</tr>
<tr>
<td>Select file 
<input name="ufile" type="file" id="ufile" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
nav33n 472 Purple hazed! Team Colleague Featured Poster

I hope this example will give you a better idea.

<html>
<body>
<form method="post" name="form1">
<select name="location">
<option value="city1" <?php if($_REQUEST['location']=="city1") { echo "selected"; }?>>City1</option>
<option value="city2" <?php if($_REQUEST['location']=="city2") { echo "selected"; }?>>City2</option>
<option value="city3" <?php if($_REQUEST['location']=="city3") { echo "selected"; }?>>City3</option>
<option value="city4" <?php if($_REQUEST['location']=="city4") { echo "selected"; }?>>City4</option>
<option value="city5" <?php if($_REQUEST['location']=="city5") { echo "selected"; }?>>City5</option>
</select>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

:)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. Happened to me too at this thread.
http://www.daniweb.com/forums/thread189490.html
For some reason, it fails to parse the [code] tags :S.

Edit: It worked ( I didn't even try to change anything :S )

nav33n 472 Purple hazed! Team Colleague Featured Poster

I hope this example will give you a better idea.

<html>
<body>
<form method="post" name="form1">
<select name="location">
<option value="city1" <?php if($_REQUEST['location']=="city1") { echo "selected"; }?>>City1</option>
<option value="city2" <?php if($_REQUEST['location']=="city2") { echo "selected"; }?>>City2</option>
<option value="city3" <?php if($_REQUEST['location']=="city3") { echo "selected"; }?>>City3</option>
<option value="city4" <?php if($_REQUEST['location']=="city4") { echo "selected"; }?>>City4</option>
<option value="city5" <?php if($_REQUEST['location']=="city5") { echo "selected"; }?>>City5</option>
</select>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
nav33n 472 Purple hazed! Team Colleague Featured Poster

I just found out that my link to the 'memberlist' no longer works. So disregard that one.

I wonder why !

nav33n 472 Purple hazed! Team Colleague Featured Poster

First of all, those are notices and not errors. Notices are those which you can totally ignore. If you don't initialize the variables and use it, you will get a 'notice'. If you want to be a good programmer, initialize every variable you use to its respective default value.
"" for a string variable, 0 for an integer variable and so on.
If you are on a local system and have access to php.ini, you can avoid notices by changing error_reporting value.
Set it to error_reporting = E_ALL & ~E_NOTICE to get all errors except notices.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Agree with kireol. And we could provide more help if you show us your code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of all these, why don't you store the result in an array ? Then, If the time difference > 1, use array_unshift to push the data to the front of the array and print it !

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you submit the form, only those checkboxes which are checked will be posted. So, If you have an array of checkbox with distinct values, you can easily know which were checked. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

no :) i didnt read the url i posted, i just post it not to make any typos for an indian name. mhm i read it it means :
"one who has found meaning (of existence)" or "he who has attained his goals". And what do you call just the opposite in that sanksrit language, by the way is this language like root of your current hindi language?

Sanskrit is the root of many languages (including English). The word Mother comes from the sanskrit word "Mathru". There are so many word that I can't recall at the moment. I didn't opt for sanskrit when I was in school, so, I am not that fluent in that language.
Hmm.. This thread has taken a 360 degree turn from Unix to Sanskrit ? Eh ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

>>Siddhant(a) in sanskrit means Theory.
Umm.... Since it my name. I have right to correct you. The perfect translation of 'siddhant' is 'principles'

Ah! Right. Thanks for the perfect translation. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

[offtopic]
I guess you already know the meaning of the word Siddhartha from the url you posted.
Siddhant(a) in sanskrit means Theory. :)
[/offtopic]

nav33n 472 Purple hazed! Team Colleague Featured Poster

And where will you get this list from ? Anyway,

//need to pull time stamp from database.
//if current time is greater than 1 hour of timestamp.
//then move $textbox_value to top of the list.
//if Not then display how much time is left before hour is up.

I hope you know how to pull the timestamp from the table.
Lets say, its $time1.

$time1 = //value from the table
$time2 = time();
$diff = ($time2 - $time1)/(60*60);
//60*60 is to convert it to hrs 1 hr = 60 mins; 1 min = 60 secs
if($diff > 1) {
// I don't know how you have that list.. I guess its an array ? Well, display it :-/
} else {
echo $diff; //display the difference
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

What do you mean by

then move $textbox_value to top of the list.

? Top of which list ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

i have PM enabled, i want to be able to see those referrals by clicking some links in my profile, better to referrals text it self.

You can. Go to your Member Certificate . You will see

Members You've Referred
When users find DaniWeb through your member certificate, they are added to your list of member referrals when they join our community.

at the bottom of the page.

serkan sendur commented: useful info +3
Ancient Dragon commented: I didn't know that -- thanks :) +36
nav33n 472 Purple hazed! Team Colleague Featured Poster

Print out the query, execute it in phpmyadmin, Or, simply add, or die(mysql_error()); ie.,

// sent from form
$textbox_value = ($_POST['code']);
$checkbox = ($_POST['checkbox']);
foreach($checkbox as $tablename) {
$query = "INSERT INTO $tablename (code, time) VALUES ('$textbox_value', NOW())";
$result = mysql_query($query) or die(mysql_error());
if($result) {
     echo("code added to $tablename database <br />");
}
else
     echo "could not add code to $tablename database <br />";
}
?>

This will make the code to print the error message on the screen if there is any.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I agree with all the people above. The php development team doesn't support php4 anymore. Php6 will soon (hopefully) be out !

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't get it ! If you have the entire address in the table, why not simply use, echo "<img src='".$row['image']."'>"; ?

csharplearner commented: i appreciate ut time. +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

What does $row print ? If you are in the subdirectory and if you want to print an image in the main directory, use .. .
ie., ../imagename.jpg

nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of having different names for your checkboxes, use a checkbox array and on submit, loop through all the selected checkbox and insert a record to the table.
For eg.,

<form name="addcode" action="<?php $_SERVER['PHP_SELF'];?>" method="POST">
 <br />
 <input name="code" type="text" value="Enter Code">
 <br />
 1:<input type="checkbox" name="checkbox" value="table1">
 2:<input type="checkbox"  name="checkbox" value="table2">
 3:<input type="checkbox" name="checkbox" value="table3">
 4:<input type="checkbox" name="checkbox" value="table4">
 <br />
 <input type="submit" name="submit" value="Add Code">
 </form>

Then, On submit,

<?php
require('FC_DB_connection.php');

//check if form has been submited
if(isset($_POST['submit'])){
//new code sent from form
$textbox_value = mysql_real_escape_string($_POST['code']);
foreach($_POST['checkbox'] as $tablename_value) {
$query = "insert into $tablename_value (col1) values ('$textbox_value')";
mysql_query($query);
}
..... etc....
 ?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Use Wamp . Easy to configure and use! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

- deleted -

I think you are right ! Just when I thought it had nothing to do with the member count (which is 4663 right now), it started behaving strangely. Daniweb has become slow as a tortoise.

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. I was talking about you mentioning Narue++ ;) Well, Nevermind!

nav33n 472 Purple hazed! Team Colleague Featured Poster

so what I telling is Narue++ .and C++ is for the human beings , and
it's the #1 fav programming language that I'm studying .

:D umm.. What are you talking about ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Build the values first and add it in the message part of the mail..
Something like this,

<?php
foreach($product as $value) {
$message .= $value ." is in the cart.<br />";
}
mail("someuser@gmail.com","Welcome",$message,"From: someone@gmail.com");
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

No. Its okay.. Even I have little knowledge on rss feeds. :( Maybe someone else could shed some light on this one.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I need to know the difference and the purpose of using an image tag like this
<img src="/images/new.jpg>" , <img src="images/new.jpg"> and <img src="../images/new.jpg">

Say for example you are in "home" directory. In home directory, there is another directory called "images".
You want to display an image called "new.jpg" which is inside images. So, <img src="/images/new.jpg"> OR <img src="./images/new.jpg"> OR <img src="images/new.jpg"> will go inside images directory and display new.jpg .
Now, consider you are in "home" directory and "images" directory is one level above "home". Then you use .. ie., <img src="../images/new.jpg"> meaning, come out of home directory (ie., go one level up) , go to images directory and display new.jpg . I hope thats clear!

nav33n 472 Purple hazed! Team Colleague Featured Poster

There is one BIG white space before <?php . :)

Try this.

<?php
      header("Content-Type: text/xml");
      $output = '<rss version="2.0"><channel>';
      $dbhost = 'localhost';
      $dbuser = 'root';
      $dbpass = '';
      $connect = mysql_connect($dbhost, $dbuser, $dbpass);
      if (!$connect) {
      die('Could not connect: ' . mysql_error());
      }
      $dbname = 'rss';
      mysql_select_db($dbname);
      //set the content type to xml
      $sql = mysql_query("SELECT * FROM article");
      $output .="
      <title> Name of your site </title>
      <description> A description of your site </description>";
      while($row = mysql_fetch_array($sql)){
      $catname = strip_tags($row['title']);
      $link = $row['link'];
      $description = htmlentities(strip_tags(substr($row['body'],0,600)));
      $output .= "
      <item>
      <title>$catname</title>
      <link>$link</link>
      <description>$description</description>
      </item>";
      }
      $output .= '</channel></rss>';
      echo $output;
      ?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Guess ! yes guys that's my girlfriend == my new dynabook 2010 DS86p/2 computer . I love it soooo much.

now I can read ebooks at the interval time @ my city and guilds
electronic engineering class. Now I don't need friends .
This is my friend.

:-O You have made your new laptop your girlfriend and you don't need friends now ? :scared:
Well, all I can say is, All the best with whatever you are upto.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Make sure you don't output anything before the header function. Even a whitespace before header can cause this warning.

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you click submit, all the form elements (radio, checkbox, select, textbox, etc) inside a form will be submitted to the script mentioned in the action of the form (if no action is specified, it will submit to the same script).

<?php
if(isset($_POST['submit'])) {
   print "<pre>";
   print_r($_POST);
   print "</pre>";
}
<html>
<body>
<form method='post'>
<input type='radio' name='person' value='1' /> Person 1 <br />
<input type='radio' name='person' value='2' /> Person 2 <br />
Name: <input type='text' name='name' /> <br />
<input type='submit' name='submit' value='submit' />
</form>
</body>
</html>

In the above example, you will see all the posted form elements. Do whatever you want with it! I don't understand what you mean by "find it in the database". If you want to search a table, then use it in the query.

$value = $_POST['textboxname'];
$query = "select * from table where user = '$value'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0 ) {
echo "Found!";
} else {
 echo "Not found!";
}

something like that ?

P.S. Its 1 am and I am going to hit the sack. Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Most probably, you installed mysql separately. But as always, It will be inside the data directory :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) n/p ! Good luck.

nav33n 472 Purple hazed! Team Colleague Featured Poster

And, the solution for your problem is, none of your code blocks are closed. if($selection == 'student') { is opened, but you have forgotten to close it after mysql_close($conn);

nav33n 472 Purple hazed! Team Colleague Featured Poster

I have a suggestion for you. Never post your username and password in a forum. :) You can still edit your post and replace username and password with null or * or whatever.
And also, fix your [code] tags .

nav33n 472 Purple hazed! Team Colleague Featured Poster

All the directories will be in data folder under mysql directory. If you have installed WAMP, for example, the databases will be in c:\wamp\mysql\data :) Look for data directory.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I guess $session->connection doesn't hold any value. But anyway, link resource is an optional parameter. Just check if you have a valid connection.
Try printing value of $q inside the function query(). Check if its ok.. Also, try

mysql_query($q) or die(mysql_error());

ie.,

function query($query){
      $result = mysql_query($query) or die(mysql_error());
     return $result;
   }

Apart from that, I can't see anything else.

nav33n 472 Purple hazed! Team Colleague Featured Poster

@SheSliq,

if ((ctype_alpha($GpoNumber) == FALSE

This needs 2 ) to close the opening braces.

if((ctype_alpha($GpoNumber) == FALSE))

Or simply,

if(ctype_alpha($GpoNumber) == FALSE)

And cwarn23 is talking about possible sql injection to your code. A bad user can inject your query with all sorts of unwanted value and take over your database! (drop,truncate, insert, whatever).
Use, mysql_real_escape_string for the user's input to avoid such thing to happen. Also, have a look at cwarn23's code. He has used all kinda prevention techniques to save you from a sql injection! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I made a dummy xml using my tables.

<?php
header("Content-Type: text/xml");
$output = '<rss version="2.0"><channel>';
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$connect = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$connect) {	
	die('Could not connect: ' . mysql_error());	
}
$dbname = 'test';
mysql_select_db($dbname);
//set the content type to xml
	
$sql = mysql_query("SELECT * FROM content");	
$output .="	
<title> Name of your site </title>
<description> A description of your site </description>";	
while($row = mysql_fetch_array($sql)){ 
	$catname = strip_tags($row['CO_NAME']);
	$link = $row['CO_ANNOUNCE']; 
	$description = htmlentities(strip_tags(substr($row['CO_DESCRIPTION'],0,600)));
	$output .= "	
	<item>
	  <title>$catname</title>
	  <link>$link</link>
	  <description>$description</description>
	</item>";
}			
$output .= '</channel></rss>';
echo $output;
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

You can use modal dialog box to do the job. Check the first example in this link for demo.
http://www.dhtmlgoodies.com/scripts/modal-message/demo-modal-message.html
You can download it here.
http://www.dhtmlgoodies.com/index.html?whichScript=modal-message

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't know if this is what you meant.

<?php
$arr = array("apple","mango","grapes");
$var = "apple 1";
foreach($arr as $value) {
	if(strpos($var,$value) !== false) {
 		echo $value ." is the closest match for ".$var."<br />";
	} 
}
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

I checked your script.

<input type="hidden" value="$autoid">

is wrong. If you want to have a hidden element with php variable's value, you should do,

<input type="hidden" name="autoid" value="<?php echo $autoid; ?>">

Secondly, Everytime there is a database operation, you have mysql_connect and mysql_select_db in your script. You can put it on top of your script, or have it in a separate file and include it on top of this script.
And lastly, You are not sanitizing your input. Use mysql_real_escape_string to protect your application from sql injections.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Your code seems okay. Is TBL_SITE_NEWS a constant ? Meaning, is it defined somewhere ? Does the values provided in the query match the column count of the table ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, read the line in red very carefully. Don't you see a missing ) after false ? Don't forget to change it everywhere.


Edit:
1. Don't create duplicate threads as it will not help you in any way.
2. Please use [code=php] [/code] tags to wrap your code. It really helps.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Used to do the same before Peter_Budo told me about the noparse tags.

You can use the noparse tags around your code block like this :-

[noparse] [code=xyz]

[/code]
[/noparse]

You can read more about the various vB tags here.

Thanks! I didn't know about tags. :)[noparse] tags. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster
$query = "select * from table where id = 100";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0 ) {
// record already exists
} else {
 // record doesn't exist, so insert.. 
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

1. I would never use form element's names like, Y M D, ie., with spaces. Try,

<input id="dmy" name="dmy" type="text" />

And in the php script,

$date = mysql_real_escape_string($_POST['dmy']);

mysql_real_escape_string escapes all the escape characters and prevent sql injections.
Also, Instead of executing the query directly, you can put it in a variable and then pass it to mysql_query. Its easier to print a variable to know what is the query you are passing to mysql_query. Ie.,

$date = $_POST['dmy'];
$query = "SELECT * FROM bookings WHERE startdate='$date'";
echo $query;
$result = mysql_query($query);

Execute the query on backend (phpmyadmin) and see if it return any rows. If it doesn't, then,
1. You either don't have any records for that date (OR)
2. You have a different date format in the table (or while passing it in the query)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:icon_rolleyes: Can't wait to see that golden shiny star ? eh ?


Edit: Oh wait, You just got it!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Use

Without a space on either side of = . ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Wow! That must be coincidence! But I don't get it. What is the point in copying threads ? Will that attract traffic in any way ?
One thing is for sure. This is going on since March 2009.