-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
[SOLVED] Form w/ checkboxes - inserting and viewing help.
mikesta707 replied to hwcasey12's topic in PHP Coding Help
use the unserialize function to turn it back into an array http://us.php.net/unserialize -
what do you mean by that?? can you please explain - i'm thinking you make a connect.php file - and its on your server - how does each html page connect to it/or it connect to each html page... or do i just put that connect.php script into each page that it is required? sorry if its a dumb question to ask... cheers eliktris What i mean by that is instead of writing your connect php everytime you want to connect IE mysql_connect(stuff, stuff, stuff); //etc. You just write that once in a file you call connect.php (or whatever) and you include it whenever you would have written it. IE include('connect.php'); Its just a little simpler. Ahh I was unaware of this. i previously thought that the form added the jeeps info to the database. So let me see if I understand correctly now. All you want to do with the database is just put how many jeeps there are right? No other information about the jeeps? In that case just make a table with 1 row, called count or whatever, and make that row an interger. everytime someone submits the form do something like $sql = mysql_query("UPDATE jeeps SET count=count+1"); that should work for incrementing the count. when you want to display it just do something like $sql = mysql_query("SELECT * FROM jeeps"); $row = mysql_fetch_assoc($sql); $count = $row['count']; echo $count; that should do what you want it to hope that helps!
-
yeah you did the same thing I did but with one extra step lol. You just set a variable to the value of a variable you already had. Its one extra line, but honestly its just as valid.
-
$data = mysql_query("SELECT * FROM iba WHERE studentid='".$_SESSION['member_ID."'"); you just wanted that specific session to be used in this query right? here you go
-
[SOLVED] sha1 password now what do I do when they try to login?
mikesta707 replied to pneudralics's topic in PHP Coding Help
yes you just sha1 the $_POST password. As far as the salt goes, I dont know too much about it, but a salt is basically a string that you base an encryption on. I don't really know if salts have their own special format, or if you just write some random string. I also dont know how the salt impacts the encryption -
I assume you want the double quotes in there? Well they are messing the code up. When you want to output double quotes, you need to use the double quote escape character, which is \". Kinda like the newline character but with quotes instead of n. <?php echo "\".substr($row['description'],0,50),\"<a href='http://xxxxxxxx.com/viewitem.php'> ...View</a>"; ?> that should fix it
-
$string = whatever; $replace = array('\"', '\"'); $to = '' $string = str_replace($replace, $to, $string); oops someone got to it first
-
Anyway to clean up a RSS feed before displaying ?
mikesta707 replied to 2levelsabove's topic in PHP Coding Help
You may be able to use a regex function like ereg() or preg_match(). But I know nothing about either of those functions, so i can't give you an example. However I will provide some helpful links! http://us.php.net/manual/en/function.ereg.php http://us.php.net/manual/en/function.preg-match.php Hope that helps! -
yes you can. have that submit page submit to a different page (maybbe sanitize.php) have that page take the variables, and populate a form with however many hidden fields that you need, and then submit the form with javascript IE $var = $_POST['my+var']; //sanitize here ?> <form action="what_ever.ext" method="post" name="MyForm"> <input type="hidden" name="hiddenfield1" value="<? echo $var; ?>"> </form> <script language="javascript" type="text/javascript"> document.MyForm.submit(); </script> <noscript><input type="submit" value="verify submit"></noscript> Hope that helps!
-
ok, a couple of things, but you are on the right track. by the way, when you want to put code, either wrap them in php tags or code tags, IE "["php"]" "["/php"]" without the quotes of course. now for your first script <?php if ($HTTP_POST_VARS['submit']) { mysql_connect("server","username","password"); mysql_select_db("jeeps"); $query ="INSERT INTO jeeps (total)"; $query.=" VALUES ('+1')"; ?> For one, whenever I want to connect to a database, i put the connect script into a file called connect.php (although you could call it what you want). and just include that script in all, or most of my pages. Whether or not this is good practice someone else can say (as i'm not an expert), but in my opinion doing this is fine now for your query. Its entirely wrong (not to sound like an A-hole hahaha). Its close, but incorrect. I would suggest that you read a few tutorials on MySQL before you start doing queries, or you will have a headache! now first thing you have to understand is the difference between databases and tables. A table is a section of a database that has different rows and columns, and a database is something that holds multiple tables. When you access information from a database, you are actually accessing a table in that database. Get it? So its not enough to just make a database. you also have to make a table Now the structure of the table is up to what you need. You could only have one field that tells how many entries there are, but assuming that your entries are in a different table, you could really just do the code I gave you above using that table name I hope that helps! good luck
-
if (!empty($feild1){ //stuff } if (!empty($field2){ //stuff } //etc. else { //do nothing } try that oops misunderstood
-
maybe is_dir('../users/'.$userid ? sorry man but that code looks like it should work. it if helps though, for an upload script i made, to test if a directory existed i used the following $uname = strtolower($_SESSION['Username']); if (!file_exists('Uploads/' . $uname)) { mkdir('Uploads/'. $uname); }
-
instead of having ((search_text like '%$keyword1%') and (search_text like '%$keyword2%') and (search_text like '%$keyword3%')) LIMIT 400"); try having ((search_text like '%$keyword1%') or (search_text like '%$keyword2%') or (search_text like '%$keyword3%')) LIMIT 400"); Or do you need the returned value to have search_text like all three keywords? hope that helps!
-
ok. Well first thing is first, if you want to do a sort of counter in php you will need to save the counter to a database, as since once the page gets refreshed, your updated counter variable will be set, rendering the variable completely useless. some background information tho. I know your completely new to php. what exactly do you know how to do? do you know anything about mysql or databases? do you know how to query a database to get information or update a database with information? ok sorry for the tough questions =P now on to your questions if you are going to go the PHP route (IE storing your counter on a database) then you are going to want to put the php that updates the counter in the page the processes the form. Now the page that actually shows the counter can go on whatever page you want it to. Actually, you can make a completely seperate page that only gets the counter from the database, and echos it (as somone above had mentioned) and just include it. Now i assume you are manually updating a random table on a database. To be perfectly honest, if you wanted to get the total numbers of entries on a database just do some simple php, IE $sql = mysql_query("SELECT * FROM tablename");//tablename is the table that your data is entered in, in your database if (!$sql){//this simply checks if the mysql query was valid. if not then stop the scrpt echo mysql_error(); exit() } $num = mysql_num_rows($sql);//this is your counter the above sends a mysql query which selects every row on the database. th mysql_num_rows tells how many rows were returned with the query, or in other words how many entries are in the database. I hope this is what you wanted, and hope this helps
-
maybe try is_dir('users/'.$userid) === FALSE for certain functions, you have to use the "===" comparison operator (I think thats what they are called) to test if the return value is true or false. Im sure someone can give a better explanation to why than me, but im pretty sure it has to do with the type of the return value. some functions return 1 for true and 0 for false
-
do you have some code already dont that we could look at? or are you just asking to be handed the code?
-
well, you could just have an input form, and have the user (you in this case I assume) input the url of the document (Probably has to be the absolute url IE http://www.mysite.com/pdfs/mypdf.pdf) and store that value into a database (after you sanitize the input of course) then once you want to make a link, you can access the database, get the URL (I assume you know how to do this, if not, i can explain in a later post) and output something like echo "<a href=\"$url\">Link text</a>"; $url is obviously the url that you got from the database. hope that helps!
-
[SOLVED] return row with multiple parameters satisfied
mikesta707 replied to neogemima's topic in PHP Coding Help
change $sql = "SELECT id, date, type, title, price FROM Equipmentposting WHERE id = $i && type = 'General Laboratory'"; to $sql = "SELECT id, date, type, title, price FROM Equipmentposting WHERE id = $i AND type = 'General Laboratory'"; Hope that helps! -
help with if else with many conditional values
mikesta707 replied to dflow's topic in PHP Coding Help
are you sure your current page name function works correct? Before you run the script, output both of the variables you are testing, and see if they have the values you expect them too -
you didnt close your span tag
-
yes foreach($_POST as $post){ $post = mysql_real_escape_string($post); } that should do what you want. Hope that helps!
-
I think there may be an easier way to do this, but the way i did it a while back was something like $array = ('dog', 'cat', 'mouse', 'dog', 'donkey'); $used = array(); $i=0; foreach($array as $key => $value){ $used[$i] = $value; if ($i != 0){ if (in_array($value, $used){ unset($array[$key]); } $i++; } There you go. might wanna check my syntax, but you get the basic idea hope that helps!
-
If i understand you correctly, you want to look into CSS
-
[SOLVED] need help query data separte with comma.
mikesta707 replied to salman1's topic in PHP Coding Help
your post didnt make much sense... You also didnt post any code.. next time you want help with some particular code I suggest you post It. But im nice so i'll try to help you =) Since you didnt post anything, Im going to assume that in your while loop, you do something like while(blah blah){ $echo $row['column'].","; } Am I right? Well instead of doing that, you can just add each result into an array, like so $i = 0; $array = array(); while (blah blah){ array[$i] = $row['column']; } and then once your loop is done you can implode the array into a string with the delimiter as a comma. IE $output = implode(',', $array); echo $output; I think thats along the lines of what you want. I hope that helps! If not please post your code and explain what you want a little better -
str_replace("'", "\'", $string); shouldnt that work?