nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, It wont go wrong unless you have made any mistake. Now open config.inc.php file in your phpmyadmin and change the username.

$cfg[$i] = 'testuser';
$cfg[$i] = '';

If even this doesn't work, then, install wamp.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Open mysql console and create a new user.

create user testuser;
grant all privileges on *.* to 'testuser'@'localhost';

This will create a new user called testuser with all the privileges. Use this user account in your script.

?

nav33n 472 Purple hazed! Team Colleague Featured Poster

its mysql -u root and mysql -u root -p password if your root has a password. Before that, you should have mysqld started. (ie, mysql server running!)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Open mysql console and create a new user.

create user testuser;
grant all privileges on *.* to 'testuser'@'localhost';

This will create a new user called testuser with all the privileges. Use this user account in your script.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Where is the while loop ? Let me show you an example.

$query="select * from table";
$result=mysql_query($query);
$row=mysql_fetch_array($result); //This will fetch only 1 record
echo $row['name'];
...
//to fetch all the records, loop through it.
while($row=mysql_fetch_array($result)){
echo $row['name'];
....
}

Well, thats the way to fetch all the records.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Code please.

nav33n 472 Purple hazed! Team Colleague Featured Poster

hmm.. Check this . It might be of some help.

nav33n 472 Purple hazed! Team Colleague Featured Poster

when the user logs in, put his username in the session. In all other pages, check if $_SESSION is set and not equal to null. If its null, then use header function to redirect to the login page.
Eg.

//after user logs in, 
$_SESSION['username']=$username;
// 
in other pages, 
if(! isset($_SESSION['username']) || $_SESSION['username']=="")) {
//redirect to login page
}

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you log in with 'root' account ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) you are welcome.

nav33n 472 Purple hazed! Team Colleague Featured Poster

concat(firstname,lastname) as name More on concat here.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you have root password, login with ur root account, create or grant privileges to a user. Check mysql manual for more information !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Grant privileges (using root account) to the user pma. I don't think pma have sufficient privileges.

nav33n 472 Purple hazed! Team Colleague Featured Poster

print out the query, execute it in mysql or phpmyadmin. I think $cps and $lps are not passed correctly OR the values of $cps and $lps doesn't return anything when you limit.

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Its not a good option to have spaces in your column names btw.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Damn.. ok.. Try this.. Update only a part of the query. For example, update only 1 field first. If it doesn't give you any error, try 2 fields. Keep doing it until you get the error. Then you will know what is causing the error.

nav33n 472 Purple hazed! Team Colleague Featured Poster

start and end are keywords. Try changing your column names to something else.

nav33n 472 Purple hazed! Team Colleague Featured Poster
"SELECT *
FROM `table3`
WHERE name LIKE '%hilgard\'s%"

Oh right ! I think I need to sleep for some more time! ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

hmm.. weird.. Did you try the other option ? escaping ' ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

What happens is, the query ends when it encounters ' in hilgard's. Escape it with \.
Eg.

'SELECT *
FROM `table3`
WHERE name LIKE '%hilgard\'s%'

To escape the single quote, you can use addslashes (or mysql_real_escape_string if your database is mysql). Or
You can use double quotes.

"SELECT *
FROM `table3`
WHERE name LIKE '%hilgard's%"

:) Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster
$i=0;
while($row=mysql_fetch_array($result)){
$photo=$row['photo'];
if($i==0) { //initially, i is 0, so it inserts a new tr. 
   echo "<tr>";
}
$i++;
echo "<td>$photo</td>"; //add the photo
if($i==4){ //adds 4 photos, once its done, make i as 0 to insert a new <tr>, end the existing <tr>.
  $i=0; 
  echo "</tr>"; 
}
}

Cheers,
Naveen

Morty222 commented: Awesome!!! +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Model No='AP22', Product Price='39.0000', Serial No='220801', Ref='TLS00700', S' at line 1

That's what the error said. It said there is an extra ' near Model No. But anyway, I dont see anything wrong with your query. Execute it in phpmyadmin/mysql and see if it returns any value. What is the error you are getting now ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
$query = "UPDATE $table SET '$io='$io2', $pp='$pp2', $sn='$sn2', $re='$re2', $sd='$sd2', $ed='$ed2', $dp='$dp2', $rn='$rn2' WHERE ID='$id'";

Look near SET '$io. An extra ' . :) Remove it!

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! :) Its easy. Just keep trying.. You ll get it. Best of luck!

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. The code that I have given you is just an example how you can do it. Change it as per your needs. List all the questions with a textbox(with different names).You may also need to save the question_ids to store it in the answer table. When the submit button is pressed, get all the answers and the question_id's (for that particular user) and save it in the table.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Create a table with all the questions. You need another table to store the answers. question_id would be the foreign key in answers table. If you are doing this question-answer script for multiple users, you need another table users, whose 'user_id' would be a foreign key for table answers.
So, questions table will have
1. question_id, primary key
2. question
Answer table will have
1. answer_id, primary key
2. question_id, foreign key from questions table
3. user_id, foreign key from users table
Users table
1. user_id , primary key
and the user details

nav33n 472 Purple hazed! Team Colleague Featured Poster

Simple. Fetch all the questions from the table and print it as follows.

$query="Select question from question_table";
$result=mysql_query($query);
$i=1;
echo "<form method=\"post\" action=\"questionpaper.php\">";
while($row=mysql_fetch_array($result)){
  $question=$row['question'];
  echo $i."." $question."<br />"; // to print 1. What is your name ?
  echo "<input type=\"text\" name=\"answer$i\" /><br />"; \\ to have unique textboxes for different questions
$i++;
}
echo "<input type=\"hidden\" name=\"count\" value=\"$i\">"; \\ to count the number of questions
echo "<input type=\"submit\" name=\"submit\" value=\"submit\">";
?>

When the user clicks on submit, get the value of i, loop through the answers.

$i=$_REQUEST['count'];
for($j=1;$j<$i;$j++){
   $answertextbox="answer".$j;
  $answer=$_POST[$answertextbox];
//insert $answer to the table
} //by the end of for loop, all the answers will be in the table.
?>

cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Difference in what ? hours ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
else if (strlen ($_POST['person_attend']) > 255)

{

$errors[] = '';

Opened { and never closed. And next time, Please post your code within code tags.

Edit: Btw, I still think there are many unclosed braces. Get a good editor, match the braces and close it accordingly.

nav33n 472 Purple hazed! Team Colleague Featured Poster

which line ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
//connection
//select db
$selected_id=$_POST['select'];
$query="Select * from table";
$result=mysql_query($query);
$options="";
while($row=mysql_fetch_array($result)){
   $name=$row['name'];
   $id=$row['id'];
   if($selected_id==$id){ 
          $selected="selected": 
    }
   else {
      $selected=""; 
   }
   $options.="<option value='$id' $selected>$name</option>";
}
?>
<html>
<body>
<form method="post" action="test.php">
Select something: <select name="select">
<?php echo $options; ?>
</select><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Cheers,
Naveen

Morty222 commented: Great answers. +1
nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
$handle = fopen('somefile.csv', 'r');
if ($handle)
{
  
    //the top line is the field names
    $fields = fgetcsv($handle, 4096, ',');
   
    //loop through one row at a time
    while (($data = fgetcsv($handle, 4096, ',')) !== FALSE)
    {
        $name=$data[0];
        $address=$data[1];
        $bday=$data[2]; //considering name will be in the first field, address in the second and bday in the third field.
        // Get all the fields from the csv file
       $query="insert into table (name,address,birthday) values ('$name',$address','$bday')";
       mysql_query($query);
    }

    fclose($handle);
}
?>

That's how you do it.

Venom Rush commented: Always adding to your rep ;) Such a great help +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

As far as your 1st question is concerned, you can get the values from a csv file and insert those to a table. fgetcsv is the function name.
I don't know from where its gonna start !
And yep, that's what I was talking about. Errorcode: 2 ! The path you have specified is not the one which its looking for !

nav33n 472 Purple hazed! Team Colleague Featured Poster

He selects a keyword from the dropdown ?
Well, then, you can simply use, $query="select * from table where col like '%$value%'"; $value is the selected value of the dropdown.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. File_priv ie.,

nav33n 472 Purple hazed! Team Colleague Featured Poster

What do you mean by best format to store the selected option ? If the <option> value is an integer, have an integer field. If its an alphanumeric, have a varchar field. Is this what you are talking about ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Bugger, well I guess the only thing left to say is "The universe is winning" ;)

:P Maybe you should contact your administrator who provides you mysql service. Btw, is this your local computer or are you testing it on the server ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

huh! Well, I dunno then. :( Sorry.

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. You can open multiple instances of phpmyadmin's while running your script :P lol..

And, user table is in mysql database.

Server: localhost - Database: mysql - Table: user "Users and global privileges"

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. user root has all the permissions AFAIK. But if you have access to phpmyadmin, go to my sql database and select table user. Check the permission option under File_priv. If its N, make it Y.
Hope that helps.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ok, but that won't cause the access error would it?

Nope. If it's outside that directory, it will generate an error with errorcode 2.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ok, it can't be grant access because I'm using administrator. I thought it might be my windows firewall preventing access but I've turned it off and I'm still getting the access denied error. Are there any other possibilities?

I've tried this on 2 separate servers not associated with one another at all and I'm getting the same access denied error.

No. I am talking about mysql user. Not the one you use to log on to windows.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Oh, btw, users.txt should be in mysql/data/dbname/ ! That's where it looks.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Your code works fine on my computer. You are probably getting 'access denied' because you don't have enough privileges for the mysql user. Use grant to grant permissions for the users.

nav33n 472 Purple hazed! Team Colleague Featured Poster

in ur retrieve.php it should be

and not $_REQUEST

$_REQUEST can handle both $_POST and $_GET. (And also $_COOKIES).

nav33n 472 Purple hazed! Team Colleague Featured Poster

I searched everywhere, but I couldn't find a select tag which could hold 2 option values. :S If you, by any chance get the answer, please post it here. I am curious. :)

But, I have an idea. Instead of passing 2 different option values, why dont you concat both the values and then pass it ? You can then separate them when the user submits the page ?
Eg.

$concat="category1:http://siteurl1.com";
echo "<select name=\"select\">";
echo "<option value=\"$concat\">something1</option>";
......
......
echo "</select>";
?>
//And when the user submits the page, 
$selectedval=$_REQUEST['select'];
list($firstvalue,$secondvalue)=explode(":",$selectedval);
//$firstvalue will have category1
//$secondvalue will have [url]http://siteurl1.com[/url].

:) This is all I could think of.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Really strange. Its working for me. I ll attach the screenshot. :S So ? Who's fault is it ?

Edit: Check if you haven't accidently deleted the image files.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! Glad you solved your problem!

nav33n 472 Purple hazed! Team Colleague Featured Poster

I dont know! You should probably post this question in css forum !

nav33n 472 Purple hazed! Team Colleague Featured Poster

I changed.. I saw and I deleted.. So, its working.. Anyway, look closely.

body {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	background-image:  url(C:/xampp/htdocs/fab/images/bgmain.gif);
	margin: 0px;
}
td {
	font-size: 10px;
}
.navon {
	background-image:  url(C:\xampp\htdocs\fab\images\nav_on.gif);
	background-repeat: no-repeat;
	background-position: left;
	height: 23px;
	width: 152px;
	text-indent: 25px;
}


.bgmain {
	background-image:  url(C:\xampp\htdocs\fab\images\main_bg2.gif);
	background-repeat: repeat-x;
	height: 287px;
}
.loginbg {
	background-image:  url(C:\xampp\htdocs\fab\images\header_01.gif);
	background-repeat: no-repeat;
	height: 40px;
	width: 368px;
}
.navt1 {
	background-image:  url(C:\xampp\htdocs\fab\images\header_05.gif);
	height: 41px;
	width: 131px;
	font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
	text-align: center;
	padding-bottom:7px;
}
a:link {
	color: #000000;
	text-decoration: none;
}

.navt2 {
	background-image:  url(C:\xampp\htdocs\fab\images\header_06.gif);
	height: 41px;
	width: 129px;
	color: #FFFFFF;
	text-align: center;
	padding-bottom:7px;
	text-decoration: none;
	font-size: 12px;
	font-weight: bold;
}
.crbg {
	background-image:  url(C:\xampp\htdocs\fab\images\crbg.gif);
	height: 22px;
	padding-top: 2px;
	padding-bottom: 2px;
	font-weight: bold;
	color: #FFFFFF;
}

.navt3 {
	background-image:  url(C:\xampp\htdocs\fab\images\header_07.gif);
	height: 41px;
	width: 129px;
	font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
	text-align: center;
	padding-bottom:7px;
}
.navt4 {
	background-image:  url(C:\xampp\htdocs\fab\images\header_08.gif);
	width: 131px;
	height: 41px;
		font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
	text-align: center;
	padding-bottom:7px;
}
.navt5 {
	background-image:  url(C:\xampp\htdocs\fab\images\header_09.gif);
	width: 130px;
	height: 41px;
		font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
	text-align: center;
	padding-bottom:7px;
}
.navt6 {
	background-image:  url(C:\xampp\htdocs\fab\images\header_10.gif);
	height: 41px;
	width: 127px;
		font-size: 12px;
	font-weight: bold;
	color: #FFFFFF;
	text-align: center;
	padding-bottom:7px;
}
.mcbg {
	background-image:  url(C:\xampp\htdocs\fab\images\mcbg.gif);
	background-repeat: repeat-y;
	width: 779px;
	padding: 0px;
}
.navoff {
	background-image:  url(C:\xampp\htdocs\fab\images\nav_off.gif);
	text-indent: 20px;
	height: 23px;
	width: 152px;
	background-repeat: no-repeat;
	font-weight: bold;
}
.leftcolheader {
	background-image:  url(C:\xampp\htdocs\fab\images\left_box_head.gif);
	background-repeat: no-repeat;
	height: 26px;
	width: 151px;
	color: #FFFFFF;
	text-indent: 20px;
	padding-top: 6px;
}
.lcolbg {
	background-image:  url(C:\xampp\htdocs\fab\images\lcolmcbg.gif);
	background-repeat: repeat-y;
	width: 152px; …