nav33n 472 Purple hazed! Team Colleague Featured Poster

Implode work for arrays, not strings.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Notice: Undefined variable: a_img in E:\web\test\photoalbum.php on line 39

Either turn off notices or initialize your variables before using them. This way, one can avoid notices.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you use print_r for an array, thats how it prints. You can't do much about it. But you can use foreach to use the array as you want it.
Example,

<?php
$x = array("teacher"=>"10","student"=>"20");
$y = array("teacher"=>"30","student"=>"40");
$z = array("teacher_no_id"=>$x,"teacher_no_name"=>$y);
foreach($z as $key => $value) {
	$output.="Main array index ".$key." -> <br />";
	foreach($value as $newkey => $newvalue) {
		$output.="Sub array index ". $newkey." -> Sub array value ".$newvalue."<br />";
	}
	$output.="<br />";
}
echo $output;
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

I do not think you will not find many people here who will spoon feed you everything to complete your homework, put some effort first.

echo

nav33n 472 Purple hazed! Team Colleague Featured Poster

sorry this is the code.............that was wrong

 <?
 session_start();
 session_unregister('emailid');
        session_register('emailid');
        session_unregister('password');
        session_register('password');
        session_unregister('conpass');
        session_register('conpass');
        session_unregister('businessname');
        session_register('businessname');
        session_unregister('streetaddress');
        session_register('streetaddress');
        session_unregister('zip');
        session_register('zip');
        session_unregister('phoneareacode');
        session_register('phoneareacode');
        session_unregister('phoneprefix');
        session_register('phoneprefix');
        session_unregister('phonesuffix');
        session_register('phonesuffix');
        session_unregister('faxareacode');
        session_register('faxareacode');
        session_unregister('faxprefix');
        session_register('faxprefix');
        session_unregister('faxsuffix');
        session_register('faxsuffix');
        session_unregister('contactfirstname');
        session_register('contactfirstname');
        session_unregister('contactlastname');
        session_register('contactlastname');
        session_unregister('comments');
        session_register('comments');


 include("header.php") ?>    

<html>
<body>
<table width="960" border="0" cellpadding="0" cellspacing="0" align="center">
         <tr>
               <td width="100%"><? include("top_banner.php") ?></td>                
         </tr>
         <tr>
              <td align="center" height="48" width="100%"><? include("horizental_menu.php") ?></td>
         </tr>

    <table align="center" cellpadding="0" cellspacing="0" width="100%" border="0" class="whitesite" >
        <!-- header -->
        <tr><td>      
    <table cellpadding="0" cellspacing="0" width="100%" border="0">
        <tr><td background="images/button_bot.jpg" width="100%" height="5" colspan="3"></td></tr>
    </table>
</td></tr>

        <!-- content -->
        <tr><td width="100%">
            <table cellpadding="0" cellspacing="0" width="100%" border="0">
                <tr>

<td width="5">&nbsp;</td>
<td width="207" valign="top" class="" align="center">
    <table cellpadding="0" cellspacing="0" width="207" border="0" align="center">
                <tr><td height="5"></td></tr>


        <tr><td align="center"  width="207">
            <table cellpadding="1" cellspacing="1" width="195" align="center" border="0">
        </table>
        </td></tr>

        <tr><td height="5"></td></tr>
        <tr><td height="5"></td></tr>
                <tr><td height="5"></td></tr>
    </table>
</td>
<td width="5">&nbsp;</td>
                    <!--  -->
                    <td valign="top">
                        <table cellpadding="0" cellspacing="0" width="100%" border="0">
                            <tr><td height="5"></td></tr>
                            <tr>
                                <td width="100%">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
                                            <tr>
    <td><img src="images/box_left.gif" width="10" height="31" alt=""></td>
    <td nowrap  background="images/box_topbg.gif" width="100%" height="31">
        <table cellpadding="0" cellspacing="0" width="100%" border="0">
            <tr>

                <td style="padding-left:5px;" class="headtitle">
                                            Service Provider Registration
                                                            </td>
            </tr>
         </table>
    <td><img src="images/box_right.gif" width="10" height="31" alt=""></td>
</tr>
<tr>
    <td background="images/box_leftbg.gif" width="10"></td>
    <td bgcolor="#FFFFFF">
                                            <table cellpadding="0" cellspacing="0" width="100%">


                                                <tr><td height="30">Register now to bid on <b>eGlazers</b> site. It's easy and <b>free</b>. Already registered? <span style="color:#005D95"><strong>Sign in now</strong></span>.</td></tr>
                                                <tr><td align="right" colspan="3" style="color:red">[ <span class="error_text">*</span> ] <span class="mandi">indicates required fields</span></td></tr>
                                                <tr><td height="15"></td></tr>
                                                <form name='form2' method='post' action="contractor_services.php" onsubmit="return val_cont(this);" > 
                                                <!-- <form name='form1' method='post' action="">-->
                                                    <tr><td>
                                                        <table border="0" cellpadding="1" cellspacing="5" align="center" width="100%" style="border:1px …
nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of

$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";

fetch the data from the database and use it.

$text = "Name \t Age \n"; //header
while($row = mysql_fetch_array($result)) {
 $text.=$row['name']."\t".$row['age']."\n"; //records
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

If you have the a working example of exporting mysql data to excel I would appreciate that.

A simple example.

<?php
$file="test.xls";
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
?>
R0bb0b commented: Even works for open office, right on! +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. probably, You didn't understand my solution. In my example, I submitted to the same page and echoed the selected option, just to give you an idea how it can be done. Anyway, I hope buddylee17's example is clear enough.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool !

nav33n 472 Purple hazed! Team Colleague Featured Poster

I haven't used it, so I can't say much. But yeah, it is possible according to Php.net

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you storing these courses in a table ?

Excel 2003 Level 1
Excel 2003 Level 2
Excel 2003 Level 3
Excel 2007 Level 1

If yes, then, just pass the id of the clicked course in the query string of the popup, query the table and fetch the relevant course. If the courses are hardcoded, then put the courses in a session array variable. For the hyperlink of courses, use the index of this array and pass it in the query string.
Simple example.

//test.php
<?php
session_start();
$courses = array();
$courses[]="course1";
$courses[]="course2";
$_SESSION['courses'] = $courses;
foreach($courses as $key => $courses_offered) {
	echo "<a href='popup.php?courseid=".$key."'>".$courses_offered."</a><br />";
}
?>

and this is popup.php

<?php
//popup.php
session_start();
$courseid = $_REQUEST['courseid'];
$courses = $_SESSION['courses'];
echo $courses[$courseid];
?>

This is just a simple example to show how you can do it..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Keep a button ("back" or something) and on click of that button, submit the page back to registration page. Then to retain the values, you can put $_POST for all the fields.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Check if extension=php_zip.dll is commented in php.ini.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, then you have to pass the array as a hidden form element. But if the user uses back button, then the chances of these values getting 'lost' is more.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Have an array, put the question numbers (or ids) you have viewed in the array. Keep the array in the session. Display last 4 questions using the last 4 indexes of the array.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Use mysql_real_escape_string for user inputs, If the input is an integer, check it with intval.

nav33n 472 Purple hazed! Team Colleague Featured Poster

What do you mean by 'update database via a form than using codes' ? Maybe this can help.
http://www.configure-all.com/php_access.php

nav33n 472 Purple hazed! Team Colleague Featured Poster

So, the problem is solved now ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

$pet_list = mysql_fetch_assoc(mysql_query("SELECT * FROM ".$db_prefix."uberpets_pet_species"));

This will definitely return 1 record.

$result = mysql_query("SELECT * FROM ".$db_prefix."uberpets_pet_species");
while($row = mysql_fetch_assoc($result)) {
$pet_list[] = $row;
}

Notice the use of while :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

http://in2.php.net/global The scope of a variable in a function is local for that function.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. and what if the user decides to close the browser instead of logging out ? Password cookie will not be deleted..

nav33n 472 Purple hazed! Team Colleague Featured Poster

The problem i am facing is--- On P2, the data entered(student/teacher) is retreived using PHP ($_POST[""]).... and the form is built in HTML

The form 'belongs' to html. So, it doesn't matter. But, have you, by any chance have .html extension to that script ? In that case, it will not work.
And, you can have html tags inside php.

<?php
echo "<html><body>This is just a test!</body></html>";
?>

Here is a simple example.

<?php
/* This is test.php */
if(isset($_POST['submit'])) {
   $selectedvalue = $_POST['type'];
if($selectedvalue == "teacher") {
echo "Welcome Teacher!";
//do something
} else {
echo "Welcome Student!";
//do something else
}
}
?>
<html>
<body>
<form method="post">
Select an option : <select name="type">
<option value='teacher'>Teacher</option>
<option value='student'>Student</option>
</select><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
nav33n 472 Purple hazed! Team Colleague Featured Poster

If user clean cookies in his/her browser, it's normally this would not work.

Exactly.
But why are you creating a password cookie ? What is the need ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Just a slight modification to Kkeith29's example. $con has to be either global, or, function q should have another parameter ie., $con (or $con will be empty). function q($sql,$con) or global $con; .

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yeah.. I am sure you can incorporate login script with this one.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I would be glad to know how you solved your problem!

nav33n 472 Purple hazed! Team Colleague Featured Poster

What ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Great!

nav33n 472 Purple hazed! Team Colleague Featured Poster

I tried microChat from hotscripts and its simple. :) Maybe, you want to give it a try ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi.. Nav..
Check this attatchment now...
Thanks.

This is fine!

nav33n 472 Purple hazed! Team Colleague Featured Poster

@Shanti, the sql you have posted (location and state.sql) are corrupted.

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. there are few bugs in the application, but, its working..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. See here, Kkeith29 has done something like that.
http://www.daniweb.com/forums/thread126462.html

nav33n 472 Purple hazed! Team Colleague Featured Poster

I tried again this way and it works. Do you have mysql_connect and mysql_select_db queries ?

<?php
$con = mysql_connect("localhost","root");
mysql_select_db("test");
function query($a) {
      $x = mysql_query($a);
      return $x;
}
function res($b) {
      $y = mysql_fetch_assoc($b);
      return $y;
}
$query="select * from users";
$res = query($query);
$columns = res($res);
echo $columns['UD_FIRSTNAME'];
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Can anyone tell me why this is? or more importantly tell me how to fix my configuration of mysql/php so it works?

Dude, I have told you many times already to assign the mysql_query result to a variable and return it. :confused:

function q($a) {
      $x = mysql_query($a);
      return $x;
 }
nav33n 472 Purple hazed! Team Colleague Featured Poster

Thanks for the advice vick_rawat but it seems to be working now. I'm using $_SESSION = $username to get it working. Also is there any tutorial you can reccomand on updating the database?

http://w3schools.com/php/php_mysql_update.asp Google is your friend ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Maybe I didnt explain well my problem.

I am using some little cookies, where I store a user information for example: nickname and password. that is working ok. After a user signs out, these cookies will be deleted.
So if the user tries to create another account from the same computer I cant stop that. this is the problem.

I want to store some extra information in cookies that will notice the user and will not let him to create more than one account.

So can anyone give me a solution?

That is simply not possible. Oh, it is possible if everyone starts using static IP. You can log the IP in a table and cross check whenever a user tries to create an account. (Mind you, Its possible only if everyone has a static IP!). Btw, its a bad idea to let the user create only 1 account. What if everyone in the family wants an account ?
:) As Rob has suggested, check for existing username or email id while registration.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I tried again and got 50% (overall)

You aren't enough frustrated then ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Is it even possible without ending the identifier.

<?php
echo <<<HEREDOC
<div>
HEREDOC;
if($i==2) {
echo <<<HEREDOC
$i is 2
</div>
HEREDOC;
}

I think this is the only possible way. I hope I am wrong. :)
Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

mysql_query(" update table2 set col2 = ( Select col1 from table1 where col3 = '$_POST["Tests"]' ) where ID = '$_POST["ID"]' ") or mysql_error()

Are you sure this didn't give any error ? I am 100% sure this will generate an error (because of the mixup of ' and "). Try this.

mysql_query("update table2 set col2 = ( Select col1 from table1 where col3 = '".$_POST['Tests']."') where ID = '".$_POST['ID']."'") or mysql_error();

P.S. Also check if $_POST and $_POST is empty.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Thanks vicky_rawat, for the reply,
BUT it is still not working, I don't know what to do?

I tried vicky_rawat's code and it works perfectly fine.. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

mysql_connect error is because the user gave wrong credentials to connect to the database.
Its not possible to call a php function or a mysql query with "onclick" event. As others have mentioned already, you can use ajax or pass the id of the record in the anchor tag and then do relevant operation.

Kavitha Butchi commented: ok, thank you fr ur time. +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

like

//...database connections...
<a href=mysql_query("DELETE FROM example WHERE age='15'")>delete</a>

something like that which works..where everything is coded in a single page rather than passing it over to the other page.

AFAIK, Its not possible.

nav33n 472 Purple hazed! Team Colleague Featured Poster
nav33n 472 Purple hazed! Team Colleague Featured Poster

Oh, and isn't "mod" a PHP or MySQL reserved word? That could very well be the other part of your problem.

Ah! Exactly. You nailed it. This will do.

update client set dod='10', `mod`='4',yod='2008' where id='120'

Notice the extra ` around mod. It will make a keyword to be used 'without any error'. But, its not a good thing to have keywords as columnnames.
Cheers,
Naveen

Edit: mod is a mysql reserve word.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you run the same select query from navicat, it works fine, but, if you run it from your script, it doesn't return any records ? I can say this for sure. Something is wrong with your script. You are doing something wrong while building dynamic query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yeah sure.

<?php
$fileatt = ""; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = ""; // Filename that will be used for the file as the attachment

$email_from = ""; // Who the email is from
$email_subject = ""; // The Subject of the email
$email_txt = ""; // Message that the email has in it

$email_to = ""; // Who the email is too

$headers = "From: ".$email_from;

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

$ok = @mail($email_to, $email_subject, $email_message, $headers);

if($ok) {
echo "<font face=verdana size=2>The file was successfully sent!</font>";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
?>

Just specify the filepath, filename and filetype (and ofcourse, from, to address).

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Welcome!