Page 2 of 3

Posted: Wed Oct 04, 2006 1:11 pm
by kakapeepee
okay :)

Code: Select all

</form> <br /> $result

Posted: Wed Oct 04, 2006 1:13 pm
by volka
The first 27 lines. Not only line 27.

Posted: Wed Oct 04, 2006 1:58 pm
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>";

Posted: Wed Oct 04, 2006 2:02 pm
by Luke
post m_config.php

Posted: Wed Oct 04, 2006 2:03 pm
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"); ?>

Posted: Wed Oct 04, 2006 2:06 pm
by Luke
where is $result defined... nowhere I can see...

Posted: Wed Oct 04, 2006 2:07 pm
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?

Posted: Wed Oct 04, 2006 2:10 pm
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

Posted: Wed Oct 04, 2006 2:12 pm
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

Posted: Wed Oct 04, 2006 2:15 pm
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

Posted: Wed Oct 04, 2006 2:24 pm
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.

Posted: Wed Oct 04, 2006 2:28 pm
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"); ?>

Posted: Wed Oct 04, 2006 2:37 pm
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.

Posted: Wed Oct 04, 2006 2:57 pm
by kakapeepee
okay i have added

Code: Select all

$result = "";
before the echo

now no more error

Posted: Wed Oct 04, 2006 3:01 pm
by volka
And what is the purpose of that? It will always print nothing[/i] in </form> <br /> $result .