-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Query Runs In Native Mysql But Not Through Php
PFMaBiSmAd replied to EricRueter's topic in MySQL Help
STOP or at least slow down. Your actual php code is putting an external value into the query. You probably have some white-space/non-printing character in front of the value that is evaluating to a zero value. When you copy/paste the query, only the printing characters are copied. Post the code for the page that is calling this page, showing the links/form that submits to this page. -
Since phpmyadmin works, which is just a php script, the next most likely problem is a permission issue with the htdocs folder or there's something specifically disabling the php language for that folder. What exactly is the URL in your browser's address bar when you use phpmyadmin on your system? Is there a .htaccess file in your htdocs folder and if so, please post the content of it. Since you got a php runtime error message from your script, php is working. You likely had cached pages in your two different browsers from when you opened the .php file directly and not through the web server.
-
Show us the opening <?php tag you are using in your code. I'll bet they are the lazy-way and time wasting short opening tag <?, which aren't enabled by default and shouldn't be used. By using the full opening <?php tag, your php code will ALWAYS be seen as being php code.
-
The file_exists requires stat() functionality. Here's the list of the http supported functionality - http://php.net/manual/en/wrappers.http.php
-
file_exists is intended to work using file system paths. It does work with some URL wrappers, but http isn't one of them.
-
Mysql_Pconnect And General Bad Practice...
PFMaBiSmAd replied to Drongo_III's topic in PHP Coding Help
Are you sure the persistent connection is actually 'working' in your case. Unless php is running as a server module on a multiprocess/multithreaded web server, all you end up with is a regular connection anyway. -
The script you found doesn't appear like it can work. It looks like someone took some functions and threw them into a class definition and then didn't completely test it. The two undefined notice messages are because that variable doesn't exist inside of the two functions it is used in. ALSO, that script is insecure. The $orderby and $sort variables are from external data, but they are being put into the query having only been passed through mysql_real_escape_string function. Since they are not STRING DATA, enclosed by single quotes in the query, they are not inside of anything they need to be prevented from escaping from. It's possible to inject sql that uses NO quotes that could care less if you passed it through mysql_real_escape_string and if put into a query at a point that is not inside of quotes, will inject sql into your query and run it on your server. For something like the $orderby and $sort variables in that code, you must validate that they only contain exactly the expected values or you must use prepared queries in order to prevent sql injection. Read through and/or start with the following post for a general pagination script - http://forums.phpfreaks.com/topic/268497-pagination/page__hl__+http_build_query#entry1378864
-
What URL are you entering in your browser to get to the form? It should be something like - http://localhost/form.html When you submit the form, your browser's address bar should be something like - http://localhost/senddetails.php
-
I'm going to guess that your $sname variable contains some sql special characters and since you don't appear to be escaping that variable before putting it into the query statement, you are getting an sql syntax error. Why are you building a query statement using two different methods of putting values into it, one for $sname and a different one for $sid? Consistency does count in programming. There's around a half-dozen three-quarters of a dozen of different things that could cause your query to not update the database. If everything is perfect up to the point of the code you did post, that query should work. Here's a list of the things that could prevent your update query from working - You don't have a database connection at the point where you are running the query. You haven't selected any database or have selected the wrong one. The php code where the query is at is not being executed. The query is failing with an error due to a wrong table or column name. The query is failing due to some sql special characters in the $sname variable. The WHERE clause is false because $sid is empty or doesn't match any id in your table. The wrong column is being used in the WHERE clause. Is the column you are trying to match id? or is it something else? The values you are updating the columns to are not compatible with the column type. The value you are updating the columns to are the same as what they already are. any more that I forgot to think of... It's up to you to troubleshoot what your code and your data are doing on your server to pin down why something does not work. You need to devise tests to check each of these possible reasons to either eliminate it as the cause of the problem or to find that it is the cause of the problem.
-
$Userfile_Type And $Userfile_Name Not Working
PFMaBiSmAd replied to xeirus's topic in PHP Coding Help
So the code wasn't identical. As to the current problem, I'm not aware of the doctype affecting uploading. It's more likely you changed your form tag but didn't refresh the page to get the changes to take effect in the form already in the browser or you have some invalid HTML somewhere on the form page that is breaking the upload form or you tried a file that was too large or it didn't have a mime type that your code expected.- 10 replies
-
- $userfile_type
- $userfile_name
-
(and 1 more)
Tagged with:
-
I recommend using hash_hmac with lowercase hex-digit output, not binary.
-
If you search the Internet for 'ajax php chained selects', you will find examples that you can examine of non-dreamweaver scripts showing how to do this.
-
A) The directory structure you actually have is not what you stated. B) Since A) wasn't true and since most FTP servers cannot create multiple folder levels at one time, the script would need to be changed to create folders one level at a time. C) If this is a one time operation, you should just use a FTP client to make a copy onto your PC, then FTP it onto the new server. D) If you need to use a php script to do this, you should probably hire a programmer.
-
This is on the list of items being worked on.
-
<?php $root = 'blog'; // starting folder (relative to where this script is at) // find the folder structure and the files $folders = array(); $files = array(); $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)); while($it->valid()){ if (!$it->isDot()){ $folders[] = $root .'/'. $it->getSubPath(); // get all folders $files[] = $it->key(); // get all files } $it->next(); } $folders = array_unique($folders); // remove duplicates include "SFTP.php"; $ftp = new SFTP("ftp host name", "ftp user name", "ftp password"); if(!$ftp->connect()) { // connection failed, display last error echo "Connection failed: {$ftp->error}<br />"; } else { echo "Connection successful<br />"; // make the folder structure foreach($folders as $folder){ if($ftp->mkdir($folder)){ echo "Made folder: $folder<br />"; } else { echo "Error: {$ftp->error}<br />"; } } // copy all the files foreach($files as $file){ if($ftp->put($file, $file)){ echo "Copied: $file<br />"; } else { echo "Error: {$ftp->error}<br />"; } } }
-
$Userfile_Type And $Userfile_Name Not Working
PFMaBiSmAd replied to xeirus's topic in PHP Coding Help
Assuming that nothing is going on in your form to make it invalid when moving between the different servers (such as a dynamically produced name='...' attribute that is empty), the $_FILES array can be empty due to - The total size of the form data exceeded the post_max_size setting. If uploads are not enabled. What does a phpinfo statement show for the post_max_size and file_uploads settings and what size of file did you try to upload?- 10 replies
-
- $userfile_type
- $userfile_name
-
(and 1 more)
Tagged with:
-
After you bind the result to the variable, you must execute $stmt->fetch(); to actually fetch the row of data from the result set.
-
Ummm, what have you tried? (leave out your actual ftp connection details when you post your code)
-
Here's a script that does the inverse - given a fixed number of rows down, produce the needed columns across. By changing this to instead set $num_cols to 3 and calculate the $num_rows, you can get it to do what you want - <?php // retrieve your data into an array in the order that you want it (faked here for demo purposes) $data[] = 'Academic Advisory'; $data[] = 'Academic Assistance'; $data[] = 'Academic Calendars'; $data[] = 'Academics Office'; $data[] = 'Administration'; $data[] = 'Adult Learners'; $data[] = 'Alumni Chapters'; $data[] = 'Alumni Events'; $data[] = 'Athletics'; $data[] = 'Campus Life At a Glance'; $data[] = 'Campus Recreation'; $data[] = 'Campus Safety & Security'; $data[] = 'Class Schedules'; $data[] = 'Counseling Center'; $data[] = 'Course Descriptions and Catalog'; $data[] = 'Department Directory'; $data[] = 'Departments & Programs'; $data[] = 'Fellowships'; $data[] = 'Finals Schedules'; $data[] = 'Class Schedules'; $data[] = 'Counseling Center'; $data[] = 'Course Descriptions and Catalog'; $data[] = 'Department Directory'; $data[] = 'Departments & Programs'; $data[] = 'Departments & Programs'; $num_rows = 12; // number of rows down if(count($data) < $num_rows){$num_rows = count($data);} // prevent empty rows if not enough data $num_cols = ceil(count($data)/$num_rows); // calculate number of columns echo "<table>"; for($i=0; $i<$num_rows;$i++){ echo "<tr>"; for($j=0; $j<$num_cols;$j++){ $element = $i + $j * $num_rows; if(isset($data[$element])){ echo "<td>$data[$element]</td>"; // cell with data } else { echo "<td> </td>"; // empty cell } } echo "</tr>\n"; } echo "</table>";
-
$Userfile_Type And $Userfile_Name Not Working
PFMaBiSmAd replied to xeirus's topic in PHP Coding Help
Define: But doesn't work either. We are not standing right next to you and don't know what you saw in front of you.- 10 replies
-
- $userfile_type
- $userfile_name
-
(and 1 more)
Tagged with:
-
I suspect you have a non-printing character (null,tab,just a \r or just a \n) before the '1' and when that CSV field is treated as a number it results in a zero value.
-
Adding Row Links From Dynamically Populated Table Withoug Using Get
PFMaBiSmAd replied to alex_ire's topic in HTML Help
Each page request must check what the current visitor can see or do on that page. Then there's no security issue with passing the id on the end of the URL or via POST data (which can be manipulated almost as easy as GET data.) For example, if I visit your profile on this forum by putting your userid/username on the end of the URL, I see only those things which I am allowed to see. If I visit my own profile on the forum, since I am the owner of the profile, I can see and change all the information, but which any other non-mod/admin member cannot. It's up to your code on each page to determine what each visitor can do on that page Edit: and using a GET parameter to specify what content a page shows is the preferred method. POST 'should' be used when submitting data to a page that once the submitted data is processed, the page either redisplays or redirects to a different page. -
There's nothing technically wrong with the query you just posted, in reply #10. Since you didn't post the error you got, there's no way anyone here can help you with the error.
-
WHERE your_column REGEXP '^[^a-z]'