nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. You are right! That makes sense..

nav33n 472 Purple hazed! Team Colleague Featured Poster

@cwarn23, I think the OP was saying, that it shows only 1 record instead of 2 !
@levsha,
Are you sure you have 2 records for that query ? If you have 2 records, it *should* display them. There is nothing wrong with the query or the while loop.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hey, sorry. I misunderstood the question.

/*
ALTER TABLE tablename MODIFY COLUMN columnname AFTER columnname 
*/
Eg. ALTER TABLE members MODIFY COLUMN date_of_birth date AFTER username

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are supposed to put mysql_fetch_array in a while loop.

while( $data2 = mysql_fetch_array($query)) {
echo $data2['firstname']; 
echo $data2['lastname'];
echo $data2['task']; 
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Very simple.

ALTER TABLE tablename ADD columnname datatype AFTER columnname
nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't recommend using mysql_fetch_row though. This will return an array with numeric indices and the script will fail if you add a new column to your table.
I personally prefer using mysql_fetch_assoc . You can also use mysql_fetch_array($result,mysql_assoc) to get the records based on its associative names.

nav33n 472 Purple hazed! Team Colleague Featured Poster

This code will throw an error at line4 saying "headers already sent"
So no echoes before the header() :)

Probably you didn't get my point. I was trying to demonstrate the use of exit after header function. Even though it will throw an error, it will still print This data is supposed to be secure... . Imagine some really secure data instead of echo statement. If you don't have exit, it will execute it (as cwarn23 has already pointed). Using exit will cut the chances of executing unwanted code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

also do we need to use the exit() below it?Will it ever get executed when already redirected to the header-location page?No it will get its turn to execute.

The exit function is used as a safety measure just in case the end user gets to echo something before header function (that will cause an error and header will not redirect).
Here is an example,

<?php
$x = empty($x) ? 1 : $x;
if($x == 1) {
	echo "Welcome";
	header("location: http://www.google.com");
}
echo "This data is supposed to be secure...";
/* more secure stuff here.... */
?>

But if you use exit after the header function, It will exit without processing any further.

<?php
$x = empty($x) ? 1 : $x;
if($x == 1) {
	echo "Welcome";
	header("location: http://www.google.com");
        exit;
}
echo "This data is supposed to be secure...";
/* more secure stuff here.... */
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

There are still some typos. $GET_ instead of $_GET. One simple suggestion though. You don't need a switch/if-elseif-else condition to find out the day. A simple array will do it. This is what I am talking about.

<?php
//nodag = Norwegian day
//endag = English Day
// dag = day
if(!isset($_GET['ok'])) { //start if
?>
<form action="" method="get">
<select name="lan">
	<option value="eng">English</option>
	<option value="no">Norsk</option>
	</select>
<input type="submit" name="ok" value="Ok">
</form>
<?php
}// end if
elseif($_GET["lan"] = "no") { //start elseif
$norwegian_days = array("Monday"=>"Mandag","Tuesday"=>"Tirsdag","Wednesday"=>"Onsdag","Thursday"=>"Torsdag","Friday"=>"Fredag","Saturday"=>"Lordag","Sunday"=>"Sondag");
$endag = date("l");
$nodag = $norwegian_days[$endag];
echo $nodag;
} // end elseif
else { // start else
$endag = date("l");
echo $endag;
}// end else
?>

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Maybe the root cause for all this confusion is the word dehasher. ;) Its not exactly a dehasher, but a hash-matcher ! :icon_cool:

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi, can you elaborate your question ?
If you are inserting the value to the table from php, you can use substr to insert only a part of a string. If you are directly inserting the record to the table, you can use mysql's substring function.
If this solves your problem, well and good.. If it doesn't, please explain your question in detail.
P.S you can only edit your post within 30 mins of posting! :)

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Pretty simple. Fetch the data from the database and place it between <textarea> tags. Here is an example.

<?php
if(isset($_POST['save'])) {
	print "<pre>";
	print_r($_POST);
	print "</pre>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Full featured example</title>

<!-- TinyMCE -->
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script>
<!-- /TinyMCE -->

</head>
<body>

<form method="post" action="live_example.php">
	<div>
		<h3>Full featured example</h3>

		<p>
			This page shows all available buttons and plugins that are included in the TinyMCE core package.
			There are more examples on how to use TinyMCE in the <a href="http://wiki.moxiecode.com/examples/tinymce/">Wiki</a>.
		</p>

		<!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->
		<div>
			<textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 80%">
<?php
$con = mysql_connect("localhost","root");
mysql_select_db("test_cms");
$query = "SELECT * FROM category where ct_id=1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$contents = $row['ct_description'];
echo $contents;
?>
			</textarea>
		</div>

		<!-- Some integration calls -->
		<a href="javascript:;" onmousedown="tinyMCE.get('elm1').show();">[Show]</a>
		<a href="javascript:;" onmousedown="tinyMCE.get('elm1').hide();">[Hide]</a>
		<a …
nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of storing the password just like a normal string, save it as an encrypted string, using SHA1 or something. This will provide you more security as well as solves your issue.
Here is an example to clarify any further doubt.

<?php
echo SHA1("ABC");
echo "<br />";
echo SHA1("abc");
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

What is the problem ? You would be selecting CourseName and courseID. So, when you post the form, You will have "MATHS" in $_POST and "101" in $_POST. Then it is all about the insert query.
Or am I missing something ? :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

The variables $table and $suburb will be empty when the page is first loaded. They will only populated once the form has been submitted - whatever other problems there may be, I think this should be avoided by using an if statement to check that the form has been submitted before executing any other code.

:) Thanks for waking me up. That is absolutely right.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you post your code ? (and print the variable $sql and post it here ?)
I guess the variable $table is empty or something.

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Wohoo! Good luck..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you using Linux server ? If yes, then make sure to check the case (lowercase/uppercase) of table and column names. Linux is case-sensitive. :)
Did you try printing out the query and executing it in mysql ?

Well, here is a quote from php.net

mysql_fetch_array
Return Values:
Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows.

As you can see, you are using the empty result resource in the while loop. Try this.

<form action="" method="post" name="Form">
   <p>Business Type:
   <select name="table" id="table">
  <option value="Plumber">Plumber</option>
  <option value="Electrician">Electrician</option>
  <option value="Painter">Painter</option>
  </select>
  </p>
  <p>Suburb:
  <select name="suburb" id="suburb">
  <option value="Bucketty">Bucketty</option>
  <option value="Kulnura">Kulnura</option>
  <option value="Gosford">Gosford</option>
  </select>
  <br />
   
  <input type="submit" name="submit" value="Submit" />
  </p>
 </form>
      

<?php
$table = $_POST['table'];
$suburb = $_POST['suburb'];
$sql = "SELECT * FROM $table WHERE Suburb='$suburb'";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0) {
	while ($row = mysql_fetch_array($result)) {
	  echo '<br/> Name: '.$row['Name'];
	  echo '<br/> Suburb: '.$row['Suburb'];
	  echo '<br/> Listing: '.$row['Listing'];
	  echo '<br/><br/>';
	}
} else {
	echo "No records found :)";
}      
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. I tried your code snippet and it worked fine. There is one thing that I'd always do after having a header, an exit. This might or might not fix the problem, but try having an exit after readfile function. :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

Try

<?php ob_start(); ?>

to turn on output buffering (should be the 1st line of your code) and

<?php ob_flush(); ?>

as the last line to flush the buffered output.

nav33n 472 Purple hazed! Team Colleague Featured Poster

1. Do you have mysql_connect ?
2. Are you selecting the database ?
3. Does that table exist ?
4. Are you sure the query is correct ? Ie., echo the query and test it in phpmyadmin/mysql console.

If your answer is *yes to all*, please post your complete code, so that others can assist.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ah! I see.. Happy learning :) Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster
<label>Content: <textarea name="Content" /><?php echo $row['Content'];?></textarea></label><br />

Pretty simple ? eh ? :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php
You should use the array returned by mysql_fetch_array and not the result resource itself. ie., $row, $row etc and not $result !

nav33n 472 Purple hazed! Team Colleague Featured Poster

I was reacting to this:

"That is why i respect a blonde cute female c++ developer too much.
She could have taken advantage of her beauty instead of coding all her life..
She just likes to produce something with her brain, she likes contemplating and observing."

Ah, It seems like you {haven't met/have no idea about} Daniweb's hardcore stalker with a never die attitude yet ? ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Annoys me. Ive learnt through working with such people on projects that a significant percentage dont work well in teams, because thier education system places a very high demand on being *the* number one through your own hard work.

You must have worked with the wrong 'set' of people for that bad experience. This has never happened to me (I have been working for past 3 yrs).
Isn't the sentence in bold a good thing ? Who doesn't want to be number one ? :)

Gets a bit annoying when the one bloke ends up rewriting all your code on his own...

Now, that sucks. Unfortunately, there are people with 'extraordinary ego' everywhere. They just want their {script/idea} to be implemented. Its horrible, I know. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

What is the big deal about these badges anyway ? It isn't a real badge that you can show off to the kids playing monopoly and say, "Take a good look at my featured poster badge. I am a famous personality. k. bai!!! :twisted: " .

:icon_rolleyes:

Stop whining Serkan. Every programmer/poster has his day. Patience is the key. Right ?

jephthah commented: w3rd +12
nav33n 472 Purple hazed! Team Colleague Featured Poster

You should escape ' before adding it to the database.
Use,

$link = mysql_real_escape_string($_POST['link']);
	$sql="INSERT INTO catalog (link)
	VALUES ('$link')";

You got that error because, the opening ' in your query is terminated when it encounters

<a target='

nav33n 472 Purple hazed! Team Colleague Featured Poster

Read this FAQ.

nav33n 472 Purple hazed! Team Colleague Featured Poster

mysql_num_rows will tell you how many records were returned by the query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Which query are you exactly using ? Because, earlier you had posted

//wrong query, quotes are all mixed up
$query = 'SELECT * FROM t_master_reg dt_reg_reminder >= '$today' AND dt_reg_end >='$today' ';

Now,

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

The above query will only work if there is an entry in the table where dt_reminder >= '2009-05-22' and dt_ended='2009-05-22'.
Do you have a record ?
If you execute the query in phpmyadmin and if it doesn't return any record, then obviously there are no records (or) you are passing the wrong query.
Echo the query and show us what it prints (not the query with variables in it).

nav33n 472 Purple hazed! Team Colleague Featured Poster

Did you print the query and execute it in mysql console or phpmyadmin ? Does that return any records ?
If Yes, then it should work in this case too.
If No, then you don't have any records in the table.

Echo the query and post it here.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Sorry, my test account :) Was trying to see if the problem only affects regular members.

We had already mentioned this problem here .

nav33n 472 Purple hazed! Team Colleague Featured Poster

Works fine for me. Probably, you didn't wait till the page was loaded.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Is there any way to get some information about posting ranks?

Earlier, Daniweb had a memberlist, which you could sort on post count and get all the information about the ranks. But it isn't available anymore as Dani wants to keep this a surprise!!!!! :P

nav33n 472 Purple hazed! Team Colleague Featured Poster

:D personal bodyguard ? eh ? LOL.. Funny!

c'mon guys don't crowd up on someone, Narue is quite capable of handling such things, let her and Serkan sort it out.

Who said Narue isn't capable of handling such things ?
It was my personal opinion and I said what I felt like saying. :twisted:

nav33n 472 Purple hazed! Team Colleague Featured Poster

Then, I think you should keep this to yourself. Announcing your inner feelings to the world wide web isn't a very good idea. Honestly speaking, this thread makes you look like a stupid. No offense, but that is the truth.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Wtf is wrong with you man ?? :-O Why don't you find someone at your office, get married, take a break and then come back ?
This isn't love. Its just infatuation and you are too old for that.

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

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 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

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

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 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.