nav33n 472 Purple hazed! Team Colleague Featured Poster

The point I was trying to make here was to show you how to use single and double quotes. http://php.net/manual/en/language.types.string.php

The variable $id is not expanding and hence you are facing problem with the id value that you are trying to pass. Read the above link to know more on what I am talking about.

nav33n 472 Purple hazed! Team Colleague Featured Poster

i tried another code that i found on the net but this code is giving me a problem with the id value that im tying to pass.my code is

<?php
require_once "../inc/functions.php";
require_once "../inc/vars.inc.php";
sessionCheck();
session_start();

$old_sessionid = session_id(); //i've added these lines

session_regenerate_id(); //i've added these lines

$new_sessionid = session_id(); //i've added these lines
function getdsgType(){
	global $desig;
	$output = '<select name="dsgn" id="dsgn">';
	$output .= '<option value="">Designation</option>';	
	foreach($desig as $k=> $v){
		if($_POST['dsgn'] == $k){
			$output .= '<option value="'.$k.'" selected>'.$v.'</option>';
		}else{
			$output .= '<option value="'.$k.'">'.$v.'</option>';		
		}
	}
	$output .= '</select>';
	return $output;
}
?>

<?php include_once "admin_templates/case_header.php"; ?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php

if(!isset($cmd)) 
{
   //display all the news
   $result = caseQuery("SELECT * 
FROM dsg, designation
WHERE dsg.dsg_id
BETWEEN 1 
AND 7 
AND dsg.designation = designation.designation order by dsg.dsg_id"); 
   if(mysql_num_rows($result))
{
$output ='<table  border="1">
<tr><td>no</td><td>Name</td><td>Designation</td><td>Phone Office</td><td>Mobile</td><td>Residence</td><td>Edit</td></tr>';
while($r=mysql_fetch_array($result)) 
   { 
      //grab the title and the ID of the news
      $name=$r["name"];//take out the title
      $dsg=$r["designation"];//take out the id
      $ph_o=$r["ph_o"];
	   $ph_m=$r["ph_m"];
	    $ph_r=$r["ph_r"];
		$id=$r["sr_no"];
$output .='<tr><td>'.$id.'</td><td>'.$name.'</td><td>'.$dsg.'</td><td>'.$ph_o.'</td><td>'.$ph_m.'</td><td>'.$ph_r.'</td><td><a href="edit.php?cmd=edit&id=$id">Edit</a></td></tr>';
}
$output .= '</table>';
echo "$output";
}
}
?>

<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
   if (!isset($_POST["submit"]))
   {
      $id = $_GET["id"];
	  echo "$id";
      $sql = "SELECT * 
FROM dsg, designation
WHERE dsg.dsg_id
BETWEEN 1 
AND 7 
AND dsg.designation = designation.designation WHERE designation.sr_no=$id";
      $result = caseQuery($sql);        
      $myrow = mysql_fetch_array($result);
      ?>
	  
      <form action="edit.php" method="post">
      <input type=hidden name="id" value="<?php echo $myrow["sr_no"] ?>">
   
      Name:<INPUT TYPE="TEXT" NAME="name" VALUE="<?php echo $myrow["name"] ?>" SIZE=30><br>
      Designation:<?php
  $query=caseQuery("select designation from dsg");
echo "<select name='dsgn' ><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($query)) { …
nav33n 472 Purple hazed! Team Colleague Featured Poster

Just put the condition

if(isset($_POST['submit']))

outside

if($_GET["cmd"]=="edit")

ie.,

if($_GET["cmd"]=="edit") {
//blah blah blah
}
if(isset($_POST['submit'])) {
//blah blah blah
}

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

You have

if(isset($_POST['submit']))

inside

if($_GET["cmd"]=="edit")

You get the form, update the details, etc etc. All fine up to this stage. But when you click on submit, the form submits to

$_SERVER['PHP_SELF']

ie., info.php .
It will never enter the first condition of

if($_GET["cmd"]=="edit")

and it never enters

if(isset($_POST['submit']))
nav33n 472 Purple hazed! Team Colleague Featured Poster

$result = mysqli_query($dbcon,$result)

Is this a typo ? Apart from that, nothing is wrong with the query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay.. Lets hope someone here know the answer.
Anyway, Good luck!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Actually, These are not mysql errors. These are user defined errors [ie., phpbb defined errors].
I haven't worked on phpBB. So, I can't tell you how phpBB handles errors. But, to hide the errors from phpBB, you can go to common.php , comment the line

set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');

and use this instead [or just comment the line].

set_error_handler(PHPBB_MSG_HANDLER);

And of course, you should set display_errors to off. This worked for me.


P.S. I am not aware of e107. But, I am sure, there will be something similar. Look at the config files and see how the error is handled.

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Emm.. Are you sure ? It works for me! Anyways, If that doesn't do the trick, try with error_reporting in php.ini .

error_reporting = ~E_ALL & ~E_NOTICE

This will not let any error/warning or notice to be displayed on the screen.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can set display_errors to off in your php.ini or add a flag in htaccess .

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hope that helps as I have read all about the australian copywrite laws.

Every country has its own copyright laws. My question is, Is there a general set of copyright rules/laws [something like, International Copyright laws ?] to which all the countries respond to ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

As simple as it sounds, Your code [what you have at the moment on the page] is correct, but you should name your script from ics2_design.html to ics2_design.php OR you should make your apache parse html files as php.
If you view the source of the page, you will see that the php code in the page isn't parsed.

:) Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

@anje, Please be more specific with your question.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ok. Great.

nav33n 472 Purple hazed! Team Colleague Featured Poster

@OP, You should have <form> tag inside the while loop. What is happening in your case is, Only the last record's data is being set in the hidden field.

In short, Just take

<form method='POST' action='temp.php'>

and put it before

$mytext .= "<tr bgcolor='#EAEAEA'>

Hope that solves your problem.

nav33n 472 Purple hazed! Team Colleague Featured Poster

what are you doing at line no. 29...?

I think you are giving the value to $row by ($row = mysql_fetch_array($sql)).
Well i have not read your program fully, so i can't understand your logic. But you but, use a condition when using while or for loop. by your condition i think your program can be gone in the infinite loop. and if it is going then please correct your line no 29. to

while($row == mysql_fetch_array($sql))

I am telling again... I am sorry but I doesn't read your program because I am in some hurry...

Have a nice day...
:)

Actually,

while($row == mysql_fetch_array($sql))

this will not make it work. This will check if $row is equal to the whatever returned by mysql_fetch_array($sql). So, it will not work.

nav33n 472 Purple hazed! Team Colleague Featured Poster

m i correct nav33n?

Didn't test, but seems good to me. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you post your latest code ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to DaniWeb. Where are you from anyway? Never heard of the name Nidhi before.

It's a sanskrit word for wealth/treasure. :)

@nidhi, Welcome to Daniweb! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Since you posted your question [?] in a thread with the same title, I am guessing you need help with the same.
I suggest you to read the sticky thread . :)

Btw, You don't have mysql_query in your code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep! Cheers :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

http://www.tizag.com/javascriptT/javascriptredirect.php Check this for javascript redirection if you can't use header.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I get this error:
PHP Parse error: parse error in D:\HostingSpaces\sachinbhatt\sachinbhatt.in\wwwroot\send_mail.php on line 73


The script is ..:

$Subject="New Inquiry";
$Message="Inquiry Details<br>";
$Message.="Name: $FullName<br>";
$Message.="Occupation: $Occupation<br>";
$Message.="Address: $Address<br>";
$Message.="City: $City<br>";
$Message.="State: $State<br>";
$Message.="Phone: $phone<br>";
$Message.="Email: $Email<br>";
$Message.="Comments: $Comments<br>";
$Headers = "From: sbhatt.salil@sachinbhatt.in"."\r\n";
$Headers .= "MIME-Version: 1.0"."\r\n";
$Headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
$Headers .= "Content-Transfer-Encoding: 7bit"."\r\n";
$r=mail("sbhatt.salil@sachinbhatt.in",$Subject,$Message,$Headers));

if(!empty($r)){
	//header("Location:ty.html");
	echo("&status=yes");
}
else{
	echo("&status=no");
}

----------------------------------------
I am not very proficient in PHP and I have not written this script as well, but using by copy/paste from some online resource.
Can anyone please help me with this..?
Many thanks in advance...

First of all, get a good editor which error checking. If you do, you will see the error yourself.
Anyways, You have an extra ) in your mail function.

Next time, please start a new thread while posting a question.

nav33n 472 Purple hazed! Team Colleague Featured Poster

What do you mean by ignore spaces ? Do you want to remove spaces ? If yes, use, str_replace function to replace a space with null. You can use strtolower function to convert capital letters to lower case. Lastly, Use header function for redirection.
Note: You shouldn't output anything before calling header function. If you have no other go, but to call header function, use ob_start(). :)[html tag, echo statement, or even a space] before calling header function. If you have no other go, but to call header function, use ob_start(). :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

1. It will not alert your message because you are already returning a value [1 or 0] from the function. Once you return a value, you are out of the function. Either return the value after the alert, or simply, put the alert after the function call.
2. It's not advisable to have any echo/print statements before calling the header function [not even a simple html tag]. This will generate a warning, which can be overridden by using ob_start. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. Where did you get that from ? Daniweb belongs to Dani. You can click on "Contact Us" at the bottom of this page to see where it is and stuff ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

And why is his name so creepily similar to yours? I might suggest watching this user, it's their first post. Another forum I'm a member of had a user do the same thing. It turned out to be a spambot.

Naveen is a common name in India, just like, Bob in United States :)

And, I don't think the user is a spambot. Or, maybe he is one, that make typos :D

nav33n 472 Purple hazed! Team Colleague Featured Poster

What are you testing btw ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

ahh i see your point
Nav.

but in your case it will require that i use 2 more files than i do allready.

but thanks for your exsample.

- hmeco

Cheers man :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I dont post the url including a user name
store the logged in details in the session
& use $session in declarations, so there is one less opening
and the session varaible is always available

Yep. Probably that would be the best way.

But, for example, if a guest user wants to check the profile of, say Y, then, session has to be started and destroyed unnecessarily.
IMO, It really depends on the type of the application the user is developing [and I can't remember, but someone pointed me sometime ago to use sessions if only necessary].

nav33n 472 Purple hazed! Team Colleague Featured Poster

Here is an example of what I am talking about.

//include_example.php
include("http://localhost/test/include_example1.php?user=test"); //works, will print Welcome test
include("include_example1.php"); //works, will print Welcome
include("include_example1.php?user=test"); //won't work, will generate a warning
//include_example1.php
<?php
echo "Welcome {$_REQUEST['user']}";
?>

And, we *can* declare a function inside a function. Here is an example.

<?php
//include_example.php
include("http://localhost/test/include_example1.php?user=Will");
?>
//include_example1.php
<?php
function attachMr($username) {
	$username = "Mr. ".$username;
	function attachLastName($username) {
		$username = $username." Smith";
		return $username;
	}
	$username = attachLastName($username);
	return $username;
}
echo "Welcome ".attachMr($_REQUEST['user']);
?>

But yep, If you solved your problem, congrats :)

Cheers!
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

You should provide the full path for include to work with GET variables.

include("http://yourhost.com/folder/file.php?user=someuser");
nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome back serkan :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Happy Republic day for Indians and Happy Australia day for Aussies :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

My bad, sorry. I had never used mysqli. Thanks to you, I checked how it works and it did work.

$mysqli = new mysqli("localhost", "root", "", "test2");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$result = $mysqli->query("SELECT * from b");
echo "Total number of records: ".$result->num_rows."<br />";
while ($row = $result->fetch_row()) { 
	print "<pre>";
	print_r($row);
	print "</pre>";
}
$result->close();
$mysqli->close();

Are you sure you are not overwriting the data in pdf ? If you print $obj2, does it print 4 records ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

If mysql_num_rows say 4, then something must be wrong with your function, fetch_row. Post your function and we will try to find out what is missing.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I suggest you to go step by step. First make first form work, then 2nd and so on. It's easy to debug that way.

michelleradu commented: he gave some gd suggestions +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

First form's <option> tag doesn't have values. So, it will never enter the switch cases of the 2nd form. And as CJesusSaves said, It's better to keep php and html separate as it is easy to manage [and you don't have to worry about escaping quotes ['] and ["]].

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you hit submit, If you want to retain the values, you can do this.

<input type='text' name='username' value='<?php echo (isset($_REQUEST['username']) ? $_REQUEST['username'] : ""); ?>'>

This will check if $_REQUEST is set. If yes, it will echo it in the form field. Else, it will echo '' [null].

nav33n 472 Purple hazed! Team Colleague Featured Poster

It's not holding because the form is getting submitted. Return false in javascript function "validate".

nav33n 472 Purple hazed! Team Colleague Featured Poster

what is a "PM" post moderator???

thanks for your friendly-not angry replies

PM means Personal message, not post moderator. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool.. Cheers :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Yep, I know they are available for free. I just don't feel the need to install oracle.

And yes, I tried your queries in mysql and I see what you are talking about. Thanks for the info :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Interesting.. What I would have liked to know was the result.. Unfortunately, I don't have oracle installed anywhere [office/home], so I can't check these queries. What happens if we run the query ? Thanks.

nav33n 472 Purple hazed! Team Colleague Featured Poster

The query is fine. I just created the table on my test database.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Definitely there is no potential danger, but as time pass this thread will go down the memory line. Once it goes pas t the 2nd page i don't think anyone will ever open it unless someone runs a search with specific key words.

Agree with that. But I guess, we don't have an option to publish articles here. Anyways, Cheers man :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Great! Good luck man :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Great! Cheers man..

nav33n 472 Purple hazed! Team Colleague Featured Poster

:P Yeps! That's absolutely right!

= is an assignment operator where as, == is a comparison operator!

nav33n 472 Purple hazed! Team Colleague Featured Poster
if($_GET['country'] == "Germany")

You are missing another "=" in your statement.

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) I used your code to insert radio button value to column age with datatype int.

<html>
<body>
<form method='post'>
<input type="radio" value="1" name="ys">
<input type='submit' name='submit' value='submit'>
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])) {
	$con = mysql_connect("localhost","root");
	mysql_select_db("test2");
	$radiobutton=$_POST['ys'];
	mysql_query("insert into a (age) values ('{$radiobutton}')");
}
?>

If this *isn't working*, you should explain what is not working and post errors if you are getting any.