Jump to content

manichean

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

manichean's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey the one I use the most is a open source javascript validator which I combine if needed with PHP to check the values check out this link and you should be well on your way :D http://www.massimocorner.com/validator/
  2. Hello, have not run the code you gave but i did notice you close your form tag before the submit button and then again after it. Im sure thats the problem. Your html [quote] <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Article Title:<br /><input type="text" name="articletitle" size="50" maxlength="50" /><br /> Article Content:<br /><textarea cols="40" rows="5" name="articletext" value="articletext"></textarea><br /></form> <input type="submit" name="submit" value="Add Article" /> </form> [/quote] should read [quote] <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Article Title:<br /><input type="text" name="articletitle" size="50" maxlength="50" /><br /> Article Content:<br /><textarea cols="40" rows="5" name="articletext" value="articletext"></textarea><br /> <input type="submit" name="submit" value="Add Article" /> </form> [/quote]
  3. The best information I can give you without going into a massive explanation is pointing you to PEAR, if you dont know about it you do now. For an explanation of what PEAR is check this link Visit : http://pear.php.net/ You will be particualrly interested in the packages list. Go there and check the Authentication package Visit : http://pear.php.net/packages.php?catpid=1&catname=Authentication This should help you on your way ;)
  4. All you have to do is get the value (presumably you storing it in a databse) and perform the following For a checkbox (you do the same for a radio button) [quote] <?php // This assumes you have pulled the info from a database storing it into $row['checkbox'] // and that you know the value to either be true or false if ($row['checkbox']){ $checkboxChecked = "checked=\"checked\""; }else{ $checkboxChecked = ""; } ?> <input type="checkbox" name="checkbox" value="checkbox" id="checkbox" <?php echo $checkboxChecked ?> /> [/quote]
  5. Hello the problem lies in this section of your code Your code: [quote] function get_open_requests($uID) { $status = 1; $query = "SELECT playersID FROM requests WHERE uID = $uID AND status = $status"; $pull = mysql_query($query); $players = unserialize($pull); print_r($players); } [/quote] Completed fixed code: [quote] function get_open_requests($uID) { $status = 1; $query = "SELECT playersID FROM requests WHERE uID = '$uID' AND status = '$status'"; $pull = mysql_query($query); $row = mysql_fetch_assoc($pull); $players = unserialize($row['playersID']); print_r($players); } [/quote] always remember a mysql_query stored into a variable storeds its RESOURCE ID # not the values obtained from the table. And always encapsulate your variables in a select or insert statment with ' ' single quotes Hope this helps ya cheers
  6. Ok I understand what you trying to do You have [quote] // Figure out the total number of results in DB: $results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM members_cat WHERE categoryid='{$cat_id}'"),0); $total_results = mysql_num_rows( $results); [/quote] I dont understand why you storing the count(*) into Num if its never used or why you try call mysql_num_rows on a result that already returns the number of rows [quote] // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) FROM members_cat WHERE categoryid='{$cat_id}'"),0); [/quote] That is the only line you should need and it will return the number of results into the $total_results variable. If you get another error just post it :P
  7. you only have to call Serialize and Unserialise if you want to store the information into a file or a database. Serialize() returns a string containing a byte-stream representation of any value that can be stored in PHP. unserialize() can use this string to recreate the original variable values. If you using php sessions to store the info accross the pages its not nessesary to perform these steps. However if you want to store the information to a file or databse then this becomes necessary Hope this helps :P
  8. did you also remove the space between the count and the (*) ? it should read [quote] COUNT(*) [/quote] and not [quote] COUNT (*) [/quote]
  9. Your line: [quote] $total_results = mysql_result(mysql_query("SELECT COUNT (*) as Num FROM members_cat WHERE categoryid={$cat_id}"),0); [/quote] Should be like this: [quote] $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM members_cat WHERE categoryid='{$cat_id}'"),0); [/quote]
  10. Here is a session example using a class I wrote called Login. For your needs create a class called user with all the information you would like to store about them and just follow the example I have given you. This is far better than calling the information from the database on each subsequent page. Another usefull tip is to modify your session.save_path in your php.ini file that way when the session is created you can open it in a local editor like notepad(if you are running php and testing the website you are creating on your local machine). I have modified mine to look like so session.save_path = "C:/Php5/sessions". As soon as the session is created i.e the user loads the page index.php if you go to that path you will check the session sitting there it will look something like this sess_2dc08acbc640cd5969383bb103b8e739 now when you capture the information on the form and move to the next page you will notice the session file changes size and stores the info you requested it to. index.php [quote] <?php //Declare class Login require_once("clsLogin.inc.php"); //Start a session so we can transferr the information across pages session_start(); //Check if the form was submitted if ($_POST['cmdLogin'] == "Login"){     //Create a Login Object with the information obtained from the form $login = new Login($_POST['txtUsername'],$_POST['txtPassword']);     //Register the session and store the Login object inside it $_SESSION['LoginObject'] = $login;     //Forward them to page 2 header("Location:page2.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="frmLogin" name="frmLogin" method="post" action="<?php echo $_Server['PHP_SELF'] ?>">   <table width="200">     <tr>       <td><label for="label">Username:</label></td>       <td><input type="text" name="txtUsername" id="txtUsername" /></td>     </tr>     <tr>       <td><label for="label2">Password:</label></td>       <td><input type="password" name="txtPassword" id="label" /></td>     </tr>     <tr>       <td>&nbsp;</td>       <td><input name="cmdLogin" type="submit" id="cmdLogin" value="Login" /></td>     </tr>   </table> </form> </body> </html> [/quote] page2.php [quote] <?php //Declare class Login require_once("clsLogin.inc.php"); //Always start the session so the page knows there is a session object session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php //Declare a variable equal to the session object Login $login = $_SESSION['LoginObject']; //Now we have associated the class with the session object we can call the class methods on our variable echo "Username: " .$login->getLoginUsername(); echo "<br />"; echo "Password: " .$login->getLoginPassword(); ?> </body> </html> [/quote] clsLogin.php [quote] <?PHP //Declare class object and its methods class login { var $username; var $password; function Login($aUsername,$aPassword){ $this->username = $aUsername; $this->password = $aPassword; } function getLoginUsername(){ return $this->username; } function getLoginPassword(){ return $this->password; } } ?> [/quote] This is quite a long example  8) if you need more help just ask Cheers
  11. I expanded it s bit in order to do checking on my local machine and the below mentioned code works [quote] $query = "SELECT COUNT(*) as Num FROM members_cat WHERE categoryid='{$cat_id}'"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result); print($row['Num']); [/quote]
  12. Hello gladiator83x, Have a look here http://www.biorust.com/tutorials/detail/221/en/ cheers
  13. Hey Saikiran, Here is a link im sure you will find usefull http://www.phpfreaks.com/tutorials/43/0.php ;D Cheers
  14. Have you checked the size of the file you are trying to upload, and then compare it to the one that is uploaded ? Maybe you are uploading a 0 byte file. Try this, create a file called 1.txt on your desktop [b]1.txt[/b] [code] Testing if the upload function is working [/code] Put these files in ur web directory [b]form.php[/b] [code] <html> <body> <form action="post.php" method="post" enctype="multipart/form-data">   <input name="Upload_File" type="file">   <input type="submit" name="Submit" value="Submit"> </form> </body> </html> [/code] [b]post.php[/b] [code] <?php $uploaddir = ""; $uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']); move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploadfile); ?> [/code] This should upload the file 1.txt from your desktop, to the path of your webserver that contains the form.php and post.php page. Let me know if you are successfull. If not tell me the type of webserver you are running, the file type you are trying to upload and are you running php 4 >= 4.0.3 or php 5
  15. Hello Yohan, Two mistakes as far as I can see [code] $uploaddir = 'c:\php\uploadtemp\IR'; //Needs to end with a trailing slash [/code] should be [code] $uploaddir = "c:\\php\\uploadtemp\\IR\\"; [/code] [code] $uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']); move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploaddir); // Move the Uploaded file to the Incomming Folder //you are specifying the uploaddir instead of the uploadfile [/code] should be [code] $uploadfile = $uploaddir . basename($_FILES['Upload_File']['name']); move_uploaded_file($_FILES['Upload_File']['tmp_name'], $uploadfile); // Move the Uploaded file to the Incomming Folder [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.