-
Posts
876 -
Joined
-
Last visited
-
Days Won
4
Everything posted by PaulRyan
-
How to include user uploaded files to index.php
PaulRyan replied to Chatrapati's topic in PHP Coding Help
I can't give you the code, you have to give it a try yourself, then post when you are stuck. It's a simple INSERT query into the database table. -
session changes automatically on form submit (using ajax)
PaulRyan replied to jasmeet's topic in PHP Coding Help
You could have just posted the code you were getting errors with and somebody would have helped. You now know for the next time you post -
Here is something I threw together, give it a try. <?PHP //### For test purposes $email = '123@yahoo.com'; //### Array of endings and url to go to $emailArray = array('@yahoo.com' => 'URL 1', '@gmail.com' => 'URL 2' ); //### Iterate over each of the array elements to find a match for the email foreach($emailArray AS $ending => $location) { if(strstr($email, $ending)) { $headerLocation = $location; break; } } //### If the ending is matched, re-direct to that url if(isset($headerLocation)) { echo 'Re-directing to: '.$headerLocation; //### If the ending is not match do something else } else { echo 'Normal form processing'; } ?>
-
How to include user uploaded files to index.php
PaulRyan replied to Chatrapati's topic in PHP Coding Help
I would personally go with the database approach. Set up a database to store user uploads, possible columns: 1 - id 2 - uploaded_by 3 - file_path 4 - upload_time Then create the upload form/page, Upload page: 1 - Create upload form 2 - On successful upload, add new record to the table Then on the Index page: 1 - Retrieve the records from the table and display them on the page. -
The errors are self explanatory, the variables and the indexes are undefined. For index.php $username = isset($_SESSION['username']) ? $_SESSION['username'] : FALSE ; $password = isset($_SESSION['password']) ? $_SESSION['password'] : FALSE ; for both login/register, add the following above the switch statement(going on a limb on this one) $act = isset($_GET['act']) ? $_GET['act'] : FALSE ; For information on the above look up Ternary Operators
-
PHP Retrieving cookies from differents pages
PaulRyan replied to Codenames's topic in PHP Coding Help
Please post the code you are stuck with, as it is pretty much impossible for us to help you properly. -
In future, please use the code tags. Try this: <?PHP $con = mysql_connect('127.0.0.1', 'root', ''); if(!$con) { die('Connection Failed: '.mysql_error()); } else { mysql_select_db('test', $con); } //### Assign get variable, if it exists $rowID = isset($_GET['number']) ? (int)$_GET['number'] : FALSE ; //### If the number doesn't exist, display error if(empty($rowID)) { echo 'No row selected to edit.'; exit; } //### Select row from database table $dbQuery = "SELECT * FROM `budget` WHERE `ID` = {$rowID}"; $dbResult = mysql_query($dbQuery) or die(mysql_error()); //### Check if a row was returned if(!mysql_num_rows($dbResult)) { echo 'No row was returned.'; exit; } else { $row = mysql_fetch_assoc($dbResult); } ?> <form method="post" action="edit_data.php"> <input type="hidden" name="ID" value="<?PHP echo $row['ID']; ?>"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td> AMOUNT </td> <td> <input type="text" name="amount" size="20" value="<?PHP echo $row['AMOUNT']; ?>"> </td> </tr> <tr> <td> PUPOSE </td> <td> <input type="text" name="purpose" size="40" value="<?PHP echo $row['PURPOSE']; ?>"> </td> </tr> <tr> <td> DATE </td> <td> <input type="text" name="date" size="40" value="<?PHP echo $row['DATE']; ?>"> </td> </tr> <tr> <td> NAME </td> <td> <input type="text" name="name" size="20" value="<?PHP echo $row['NAME']; ?>"> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit value" value="Edit"> </td> </tr> </table> </form>
-
session is displaying error after execution
PaulRyan replied to Pawan_Agarwal's topic in PHP Coding Help
Please show us the code from counter.php and the top 20 or so lines from index.php. -
Trying to make a simple form to send to PHP. PLEASE HELP!
PaulRyan replied to Joefuss's topic in PHP Coding Help
QuickOldCar, the variable $user_input should be inside of the if statement, otherwise it will display an error. Providing that errors are set to be displayed, which they should be. <?PHP if($_SERVER['REQUEST_METHOD'] == 'POST') { $user_input = isset($_POST['user_input']) ? trim($_POST['user_input']) : FALSE ; if(empty($user_input)) { echo 'No user input entered.'; } else { echo 'User Input: '. $user_input; } } ?> <form action="" method="POST"> <input type="text" name="user_input" size="20"> <input type="submit" name="press" value="Press da button!"> </form> -
Trying to make a simple form to send to PHP. PLEASE HELP!
PaulRyan replied to Joefuss's topic in PHP Coding Help
Codelinx, that wouldn't do anything, his submit is not named "submit" it is named "press". I would personally go with: <?PHP if($_SERVER['REQUEST_METHOD'] == 'POST') { ..... } ?> -
Use a database to store all of the file names and file paths, then do a search on the database instead of searching the directory each time.
-
Getting the next weeks deadlines from the database
PaulRyan replied to andrew_biggart's topic in PHP Coding Help
You need to put back ticks around the column name as you have a space in its name. `job status` Personally, I replace all spaces with underscores to avoid such errors and looks better in my opinion. -
need help with a simple php/mysql download tracker
PaulRyan replied to thcbutterz's topic in PHP Coding Help
You have not connected to the database as far as I am aware, so you need to do that first. Secondly, you are not executing the MySQL queries, just merely assigning them to a variable. You need to look into PHP a bit more look at $_GET. Then you need to move away from MySQL and look to MySQLi also, so read up on that too. -
I personally would load the news from the MySQL table into a JS array and then cycle through them 1 by 1. You could create a scrolling div or just fade the news in and out using jQuery or plain JS.
-
mysqli prepared statement select null query problem
PaulRyan replied to benoit1980's topic in PHP Coding Help
Try using this: $stmt = $mysqli->prepare("SELECT * FROM $tbl_name WHERE phone_number=? AND group_leader IS NULL") or die($mysqli->error); -
Always use return. Using echo will echo out the content where ever the function is called, so if you called the function before the header etc, it would display whatever you echo above the header. Using return, you assign the function call to a variable for use later on in the code.
-
mysqli prepared statement select null query problem
PaulRyan replied to benoit1980's topic in PHP Coding Help
Please post your updated code, so I can see the changes. -
mysqli prepared statement select null query problem
PaulRyan replied to benoit1980's topic in PHP Coding Help
You do not need 2 WHERE clauses. "SELECT * FROM $tbl_name WHERE phone_number=? AND group_leader IS NULL" 2 hours well spent -
You do not need the dot between the 2 variables, as this adds an actual dot between the 2 values. Use this instead: <img id='cpt_img' src='{$path}{$img}'>
-
Bump all you want, you need to post your code before anyone will think about helping.
-
Does something like HTTP_GET_RESPONSE exist?
PaulRyan replied to freakkater's topic in PHP Coding Help
file_get_contents -
1 - An error in your query most likely. 2 - isset 3 - The function sqlerr does not exist or you haven't included the relevant file for it to exist.
-
@Muddy_Funster - Kudos, had a complete brain fart with that.
-
You are using "mysql_fetch_array($result)" which actually returns an array of the values using numbers e.g. "$row[0]" Try using this: while ($row = mysql_fetch_assoc($result))