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.
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.
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.
?
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!)
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.
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.
Code please.
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
Can you log in with 'root' account ?
:) you are welcome.
If you have root password, login with ur root account, create or grant privileges to a user. Check mysql manual for more information !
Grant privileges (using root account) to the user pma. I don't think pma have sufficient privileges.
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.
:) Its not a good option to have spaces in your column names btw.
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.
start and end are keywords. Try changing your column names to something else.
"SELECT * FROM `table3` WHERE name LIKE '%hilgard\'s%"
Oh right ! I think I need to sleep for some more time! ;)
hmm.. weird.. Did you try the other option ? escaping ' ?
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
$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
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 ?
$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!
You are welcome! :) Its easy. Just keep trying.. You ll get it. Best of luck!
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.
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
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
Difference in what ? hours ?
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.
which line ?
<?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
<?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.
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 !
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.
Yep. File_priv ie.,
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 ?
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 ?
huh! Well, I dunno then. :( Sorry.
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"
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.
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.
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.
Oh, btw, users.txt should be in mysql/data/dbname/ ! That's where it looks.
in ur retrieve.php it should be
and not $_REQUEST
$_REQUEST can handle both $_POST and $_GET. (And also $_COOKIES).
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.
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.
You are welcome! Glad you solved your problem!
I dont know! You should probably post this question in css forum !
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; …