?action=something

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

okay :)

Code: Select all

</form> <br /> $result
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The first 27 lines. Not only line 27.
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

Code: Select all

<?php
include "m_config.php";
echo "<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<form name=\"decision\" method=\"post\" action=\"http://127.0.0.1/web/file.php\">
<input type=\"hidden\" name=\"action\" value=\"add\">
<input name=\"name\" type=\"text\">
<input name=\"lname\" type=\"text\">
<br />
<label title=\"choice\" >
yes <input name=\"choice\" type=\"radio\" value=\"yes\" checked>
No <input name=\"choice\" type=\"radio\" value=\"no\"></label>

<input type=\"submit\" value=\"submit\" />
</form> <br /> $result
".read()."
</body>
</html>";
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

post m_config.php
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

Code: Select all

<?php
$hostname = "127.0.0.1";
$username = "root";
$password = "dfdfd";
$database = "something";
$table_prefix = "m_";



	mysql_connect($hostname, $username, $password) or die("Could not connect to MySQL");
	mysql_select_db($database) or die("Could not connect to MySQL"); ?>
Last edited by kakapeepee on Wed Oct 04, 2006 2:08 pm, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

where is $result defined... nowhere I can see...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

And where do you think $result is set? There's nothing in that script that assigns anything to $result; it is simply "used"

kakapeepee wrote:if(!$query)
{
$result = "An error has occured";
}
else
{
$result = "Thanks...";
}
That's in another script?
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

well no those are the codes , how to define it? and why

i thought $result = "something" will display something when i used it in some html part:S
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

kakapeepee wrote:i thought $result = "something" will display something when i used it in some html part:S
Then tell me where there is a $result = "something" in
kakapeepee wrote:

Code: Select all

<?php
include "m_config.php";
echo "<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<form name="decision" method="post" action="http://127.0.0.1/web/file.php">
<input type="hidden" name="action" value="add">
<input name="name" type="text">
<input name="lname" type="text">
<br />
<label title="choice" >
yes <input name="choice" type="radio" value="yes" checked>
No <input name="choice" type="radio" value="no"></label>

<input type="submit" value="submit" />
</form> <br /> $result
".read()."
</body>
</html>";
:?:
Is it in m_config.php? If so, please post the contents of m_config.php
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

when the query is executed
there is an if statement

Code: Select all

if(!$query)
				{
					$result =  "An error has occured";
				}
				else
				{
					$result = "Thanks...";
				}
$result is filled now with one of the conditions


above in the displayed actually page's html, i have added $result.

Code: Select all

</form> <br /> $result
".read()."
</body>
</html>";

i thought THANKS... or whatever message will appear there below the form



* m_config.php is in some previous post
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

kakapeepee wrote:when the query is executed
there is an if statement

Code: Select all

if(!$query)
				{
					$result =  "An error has occured";
				}
				else
				{
					$result = "Thanks...";
				}
Where? I don't see it. Neither in
kakapeepee wrote:

Code: Select all

<?php
include "m_config.php";
echo "<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<form name="decision" method="post" action="http://127.0.0.1/web/file.php">
<input type="hidden" name="action" value="add">
<input name="name" type="text">
<input name="lname" type="text">
<br />
<label title="choice" >
yes <input name="choice" type="radio" value="yes" checked>
No <input name="choice" type="radio" value="no"></label>

<input type="submit" value="submit" />
</form> <br /> $result
".read()."
</body>
</html>";
nor in
kakapeepee wrote:

Code: Select all

<?php
$hostname = "127.0.0.1";
$username = "root";
$password = "dfdfd";
$database = "something";
$table_prefix = "m_";



	mysql_connect($hostname, $username, $password) or die("Could not connect to MySQL");
	mysql_select_db($database) or die("Could not connect to MySQL"); ?>
Tell me the filename and line number where
kakapeepee wrote:

Code: Select all

if(!$query)
				{
					$result =  "An error has occured";
				}
				else
				{
					$result = "Thanks...";
				}
starts.
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

guys :P

that's the whole file, FIX IT

Code: Select all

<?php
include "m_config.php";
echo "<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<form name=\"decision\" method=\"post\" action=\"http://127.0.0.1/web/file.php\">
<input type=\"hidden\" name=\"action\" value=\"add\">
<input name=\"name\" type=\"text\">
<input name=\"lname\" type=\"text\">
<br />
<label title=\"choice\" >
yes <input name=\"choice\" type=\"radio\" value=\"yes\" checked>
No <input name=\"choice\" type=\"radio\" value=\"no\"></label>

<input type=\"submit\" value=\"submit\" />
</form> <br /> $result
".read()."
</body>
</html>";

	if(isset($_POST['action']) && $_POST['action'] == "add") 
	{
			$name = $_POST['name'];
			$lname = $_POST['lname'];
			$choice = $_POST['choice'];
			$date = time();
			$ip = GetHostByName($_SERVER['REMOTE_ADDR']);

			if(!$name || !$lname)
			{
				$result = "Please fill all the required fields";
			} 
			else 
			{
				$query = mysql_query("insert into m_record (name,lname,yesno,date,ip) values('$name','$lname','$choice','$date', '$ip')");
				if(!$query)
				{
					$result =  "An error has occured";
				}
				else
				{
					$result = "Thanks...";
				}
			}
	}
function read()
{
	global $total;

	$total = 0;

	$query = mysql_query("select *  FROM m_record where yesno='yes'");
	while($array = mysql_fetch_array($query))
	{
	$total += 1;
	}
	return  $total;
}
?>

m_config.php

Code: Select all

<?php
$hostname = "127.0.0.1";
$username = "zaher";
$password = "okk";
$database = "marriage";
$table_prefix = "m_";



	mysql_connect($hostname, $username, $password) or die("Could not connect to MySQL");
	mysql_select_db($database) or die("Could not connect to MySQL"); ?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

At which line is </form> <br /> $result and at which if(!$query)?
isn't $result used before it is set? Yes, it is.
kakapeepee
Forum Newbie
Posts: 14
Joined: Wed Oct 04, 2006 8:40 am

Post by kakapeepee »

okay i have added

Code: Select all

$result = "";
before the echo

now no more error
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

And what is the purpose of that? It will always print nothing[/i] in </form> <br /> $result .
Post Reply