Please Bang dani Help me asap, i'll say thank' you and thanks
Salam Open Source, please cc to my email <EMAIL SNIPPED> thx
:-O What the ....
Please Bang dani Help me asap, i'll say thank' you and thanks
Salam Open Source, please cc to my email <EMAIL SNIPPED> thx
:-O What the ....
And the title, even that doesn't make any sense.
Posting some relevant code would help.
You are welcome! :)
$value = isset($_POST['name']) ? $_POST['name']:"10";
? is called Ternary Operator. In the example above, I am checking if $_POST is set and has a value. If has a value, I am assigning it to the variable $value. If it doesn't have any value, I am assigning 10 to $value.
You can read more about ternary operator here.
http://in.php.net/operators.comparison
<input type="text" name="ch1" value = "<?echo $_POST; ?>" />
This will retain whatever value the user had entered in the textbox "ch1".
Edit: I don't recommend using <? (or short tags). Short tags are turned off on most servers, which would result in printing the php code to the screen. Use <?php instead.
I don't see element guess_value in this code! :) Well, here is an example.
<?php
$value = isset($_POST['name']) ? $_POST['name']:"10";
?>
<html>
<body>
<form method='post'>
<input type='text' name='name' value='<?php echo $value; ?>' readOnly='readOnly'>
<input type='submit' name='submit' value='submit'>
</form>
</body>
</html>
I have hard-coded value 10. You can replace it with whatever value (of the variable) you are printing in guess_value.
Can you post your code ? You have to retain the value of the textbox. :)
FYI, Notice is not an error and can be turned off with different Error reporting values..
Edit: It is kind of an error, but can be ignored. (Doh!)
I think I totally misunderstood your question! My apologies. :)
The script works, but I would like to sent the POST data using the php "header" function instead so the headers don't pass from the client.
I am quite confused what you actually want. If you want to redirect the user to some other page using header function, you can pass the POST data in the query string. header("location: somepage.php?name=$name&age=$age");
$q="SELECT id FROM login WHERE username='$username'";
$sql=mysql_query($q);
if (@mysql_num_rows($sql)==1) {
$arr=mysql_fetch_array($sql);
$id=$arr["id"];
}
:-/
@nav33n : I chose not to give him the exact query but describe what it should be like and let him do the work.
I know. But I was in a good mood to write it for him :)
Because the result resouce contains 'no rows' and then goes to the function to preform the mysql_num_rows it cannot(due to having no rows - I dont know why) and then goes to the or die statement and throws the "Error".
No. result resource simply wouldn't know if it returns "No rows" or "Rows". Does the above function work for you ? If it doesn't, then, I am sorry, I don't know what else to say.
http://www.echoecho.com/htmlforms10.htm Check which questions he has answered and use "checked" to mark the answers which the user has already answered.
What exactly is the error message :-/
The function is fine. The only place where you can go wrong is while passing the argument to the function. Make sure $a is a valid result resource.
function getRows($result_resource) {
return mysql_num_rows($result_resource);
}
$query = "select * from table where column='somevalue'";
$result = mysql_query($query);
$totalRows = getRows($result);
echo $totalRows;
Oh, btw, If your query isn't a valid one, ie., if the table or the column doesn't exist, it will return an error ! :)
Cheers!
Nav
:D So, its fixed now ?
Hmmm... Actually I think I know what may be the problem I think because I am calling the mysql_num_rows from a function then directly?
May be. Are you passing this result resource to the function ? If you post relevant code, it would be very helpful !
Thanks for the quick reply,
Unfortunatly all that happens is the page reloads.
Thanks anyway for the reply
page reloads ? Are you sure ? :-O It should redirect to the page success.php !
You got it all wrong. $b doesn't return any rows. It just return result resource, which can be used in
* mysql_num_rows to know how many rows were returned.
* mysql_fetch_array/mysql_fetch_assoc/mysql_fetch_row/mysql_fetch_object to get the values of the rows .
Just out of curiosity, does this mean that scripts are loaded into the PHP interpreter in their entirety, so that anything can happen to the file during execution and the its execution will be unaffected?
Yeah, I think so too!
I can't explain you any better :( Post all the relevant code here. And please use code tags.
<?php
//install2.php
if(isset($_GET['unlink']) && $_GET['unlink']=="true") {
unlink("install.php");
unlink("install2.php");
header("location: success.php");
}
//rest of the code here
echo "<a href='install2.php?unlink=true'>Click here to remove the installation files ! </a>";
?>
Works on local machine. I haven't tested it on server!
If you want to do the same with a button, use a hidden variable, set some value to it and depending upon that value, repeat this action :)
select count(*) as total from user group by jobs
-----------------------------
Total ------ Jobs
-----------------------------
10 ------> Unemployed
20 ------> Employed
Cheers!
Well, You can do it in quite easily. Before redirecting them to the page where they book a room, use $last_inserted_mysql_id = mysql_insert_id();
to get their clientID.
After getting their clientID, you can direct them to "Book a room" page along with their clientID or save the clientID to a session variable and use it in your booking table.
There's no reason you can't change "TEXTAREA" to "textarea" in the code.
You are absolutely right ! :icon_lol:
IE will still report the tag in upper case, however, if queried. Note that if you use a transitional DOCTYPE the case shouldn't be an issue for validation.
Hmm! I didn't know that..
Where are you inserting the value to client table ?
last_insert_id() in mysql or mysql_insert_id() in php gets the value of the autoincrement field from the last insert query.
Eg.
//using mysql's LAST_INSERT_ID()
// considering clientID as auto increment - primary key
$add_to_client_query = "insert into client (name,age) values ('test','20')";
mysql_query($add_to_client_query);
$add_to_booking_query = "insert into booking (busname, totalseats,clientID) values ('Air bus','30',LAST_INSERT_ID())";
mysql_query($add_to_booking_query);
//using php's mysql_insert_id()
// considering clientID as auto increment - primary key
$add_to_client_query = "insert into client (name,age) values ('test','20')";
mysql_query($add_to_client_query);
$last_inserted_mysql_id = mysql_insert_id();
$add_to_booking_query = "insert into booking (busname, totalseats,clientID) values ('Air bus','30','$last_inserted_mysql_id)";
mysql_query($add_to_booking_query);
I hope thats clear ?
Cheers!
I found this example. http://www.quirksmode.org/dom/cms.html
But again, he uses 'TEXTAREA' and not 'textarea' :-/
Using the example given in the website,
<html>
<body>
<head>
<script type="text/javascript">
var editing = false;
if (document.getElementById && document.createElement) {
var butt = document.createElement('BUTTON');
var buttext = document.createTextNode('Ready!');
butt.appendChild(buttext);
butt.onclick = saveEdit;
}
function catchIt(e) {
if (editing) return;
if (!document.getElementById || !document.createElement) return;
if (!e) var obj = window.event.srcElement;
else var obj = e.target;
while (obj.nodeType != 1) {
obj = obj.parentNode;
}
if (obj.tagName == 'TEXTAREA' || obj.tagName == 'A') return;
while (obj.nodeName != 'P' && obj.nodeName != 'HTML') {
obj = obj.parentNode;
}
if (obj.nodeName == 'HTML') return;
var x = obj.innerHTML;
var y = document.createElement('TEXTAREA');
var z = obj.parentNode;
z.insertBefore(y,obj);
z.insertBefore(butt,obj);
z.removeChild(obj);
y.value = x;
y.focus();
editing = true;
}
function saveEdit() {
var area = document.getElementsByTagName('TEXTAREA')[0];
var y = document.createElement('P');
var z = area.parentNode;
y.innerHTML = area.value;
z.insertBefore(y,area);
z.removeChild(area);
z.removeChild(document.getElementsByTagName('button')[0]);
editing = false;
}
document.onclick = catchIt;
</script>
</head>
<p> This is a test! </p>
</body>
</html>
In every page you use session variables, you should have session_start(). :)
Great! Cheers :)
You are welcome :)
but how would i actually write the url dynamically upon uploading, to database. say i am uploading into a folder called 'album1' 5 mp3s. now how would i insert in database album1/mp3.mp3, without hardcoding it like $path = "album1";
Check move_uploaded_file . You have to specify the 'destination' where you want to upload the file. Use the same destination :-/ Right ?
1. Yes. Since you know where you will be uploading the file, you can save the foldername as albumname
2. By using multiple <input type='file' >
tag
I am not sure if the examples in these links work, but, this is how you do it.
http://www.phpeasystep.com/workshopview.php?id=2
http://www.plus2net.com/php_tutorial/php_multi_file_upload.php
In your dblayer.php, echo current working directory. Depending on which directory you are in, you can use ../ to go back one step to previous directory, ../../ to go back 2 steps and so on..
ie., If the file is in public_html/common/dblayer.php , using ../ will take you to the folder common and ../../ will take you to public_html :)
Your question raises more questions than answers !
No. What you said is correct.
Yeah. Try it out. :)
Varchar is the best option what i know...because char is fixed length...but varchar is automatically change size based on the input....If u use char, than memory wastage is more...
Ah! You beat me by 4 mins :twisted:
http://www.mssqlcity.com/FAQ/General/char_vs_varchar.htm
Summary: If you specify column's datatype as char(20) and you enter a value, say, "test", mysql still uses 20 bytes.. But if the column's datatype is varchar, and you enter "test", it uses only 4 bytes.. The best place to use char is when you are 100% sure that you save only a fixed length value, for example, a boolean "Y" or "N".
P.S. I am not too sure about the bytes used. This is just to give you a gist!
In the table there is no value of c and hence nothing is returned
What is the value of $b?
$b will still hold a result resource. Check Return values here..
http://in.php.net/function.mysql-query
<input type="text" name="ch1" disabled= "true" id="ch1" />
<?
if( $_GET["e"] == 3 || $_GET["e"] == 4) {
echo "<script>document.getElementById('ch1').disabled = ''; </script>";
}
?>
:)
<offtopic>
Strangely, http://www.w3schools.com/htmldom/prop_text_disabled.asp says textObject.disabled=true|false
But, when I use <input type= "text" id='ch1' name ="ch1" disabled='false' />
it doesn't work.. It still disables the textbox :S
</offtopic>
Anyways, I hope I am wrong and someone else have a way to enable already disabled textbox without using javascript.. :)
As far as I know, once you have printed a html element, you can't change it (unless you use javascript). Even almostbob's code decides whether to enable or disable the textbox at runtime.
Do you get any error ? And, you don't have session_start(); in this script :-/
If it is disabled by default and on certain condition, you want to enable it, you have to use javascript.
Hi there! The issue is with innerHTML! Check this link..
http://www.developer-x.com/content/innerhtml/
You can have a field in your table to store the total questions answered by the user in bit format.
For example, if there are 10 questions and the user has answered 4 of it, save, 1111000000 to the table. Then, when the user logs in next time, show only questions starting from 5th. This way, even if the user has answered his questions randomly, like, 1st, 3rd, 5th and 6th, you will know which questions he has answered and which questions he has not ! :-/ Umm..If the user has to answer the questions sequentially, then, you can directly save the question number to the table!
You are doing it wrong.. $result = mysql_query($query);
This will execute the query and return the result resource. You have to then use mysql_fetch_array (mysql_fetch_row/mysql_fetch_assoc/mysql_fetch_object) !
Read it here.. http://in.php.net/function.mysql-query
$query = "SELECT * FROM item WHERE item_id = '1'";
$result = mysql_query($query);
$row = mysql_fetch_array($result); //if it returns only 1 row else use while loop
$image_path = $row['image_path'];
echo "<img src ='".$image_path."'>";
?>