-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Returning an array from a simple mysql request
PFMaBiSmAd replied to spenceddd's topic in PHP Coding Help
One table would work and would allow for an limited number of different types to be used - // if there is a table setup with id, user_id, type, value (type is either skills or categories and value is the single (one) numeric value) // you would have data like - // id, user_id, type, value // 1 10 skills 56 // 2 10 skills 13 // 3 10 skills 1 // 4 10 skills 98 // 5 10 categories 56 // 6 10 categories 13 // 7 10 categories 1 // 8 10 categories 98 // the query would look like this - $array = array(12,13,1,86); // starting array of values to find $in = implode(',',$array); $query = "SELECT user_id FROM the_table WHERE (type = 'skills' AND value IN($in)) OR (type = 'categories' AND value IN($in))"; echo $query; -
Returning an array from a simple mysql request
PFMaBiSmAd replied to spenceddd's topic in PHP Coding Help
You are asking for the intersection of two sets of data. It currently cannot be done 'simply' by using built-in mysql functions. You will either need to correct your table design (storing a list of values in a column is fine if all you are doing is storing/retrieving that information or if you are searching if one of the values matches another single value) or you will need to dynamically build your query string with a separate term to check each value in the starting array. FIND_IN_SET() would be the mysql function to use to find rows where a given (single) value matches one of the values in a list in a column. -
Simple e-mail form only working with some e-mail accounts?!
PFMaBiSmAd replied to pixelchicken's topic in PHP Coding Help
It would take seeing your code to be able to even begin to tell you why it is not working. -
Access denied for user 'ODBC'@'localhost'
PFMaBiSmAd replied to WWW_9hub_Net's topic in Third Party Scripts
http://php.net/preg_match -
Ummm. A HTML doctype, a HTML <html> opening tag, and a HTML <head> tag are all HTML... <!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>
-
Access denied for user 'ODBC'@'localhost'
PFMaBiSmAd replied to WWW_9hub_Net's topic in Third Party Scripts
No, because the code needs to get an IP address into $connecting_ip so that the rest of the code in that file will work. -
Welcome to php's biggest blunder (and the web hosts who continued the blunder by not turning them off when the security problem became known), register_globals. You can also set the $_SESSION variable by submitting your form with the name='email' field or by putting ?email=anything a hacker wants here on the end of the URL when your page is requested. A lot of web sites where taken over because this allows a hacker to set the session variables that define them as an administrator to a script. register_globals were turned off by default in php4.2 in the year 2002, they finally trigger a deprecated error message in php5.3, and they have been completely eliminated in php6. Your web host should have turned them off long 7 years ago. You can and should turn them off yourself in the master php.ini (when you have access to it), in a .htaccess file (when php is running as an Apache Module) or in a local php.ini (when php is running as a CGI application.)
-
What web server are you using (Apache, IIS, other) and is php running as a server module or as a CGI application?
-
Warning: mysql_fetch_assoc(): supplied argument is not a valid
PFMaBiSmAd replied to bcode's topic in PHP Coding Help
Empty tables and queries that return zero rows DON'T cause mysql_ function errors. Your query failed to execute due to an error. In just looking at it, you need some single-quotes around '$names[0]' and '$names[1]' in the query to make those values string data instead of column names. -
Without even seeing your code I can tell you that it does not have any logic in it for error checking, error reporting (and logging), and error recovery to get it to tell you why it did not insert anything into the database, so it will be a little hard for anyone in a forum to tell you why either. If you look at any of the existing threads at phpfreaks.com where queries fail to work, you will find that in almost every case, the suggestion is to add some logic to test for and display any errors that are occurring. Short-answer: If you are sure the query is actually being executed, echo mysql_error() right after the query to find out why the query failed.
-
Access denied for user 'ODBC'@'localhost'
PFMaBiSmAd replied to WWW_9hub_Net's topic in Third Party Scripts
The other code has a section where you can restrict access to a specific range or list of IP addresses. I don't know if the script uses the IP for anything more specific (such as identifying users...), so the following may or may not work - If it is acceptable that anyone who is allowed to connect through the proxy (and its' IP) address is also allowed to use this script, then the change I posted above would return the proxy's IP address for all those users. Otherwise, you would need to find out which, if any, of the HTTP_X_ headers are being supplied by the proxy and troubleshoot why the code is not outputting the actual IP address of the client. -
Access denied for user 'ODBC'@'localhost'
PFMaBiSmAd replied to WWW_9hub_Net's topic in Third Party Scripts
You are doing this on a local network/Intranet? Are there any local proxy servers (caching servers) involved in the network that one or more users will connect to the server through? That code is attempting to find the 'real' IP address of the client computer. If all your client computers are connecting to the server without going through a proxy server, then I would just put the following line of code - return $direct_ip; Immediately before the following line of code - if (empty($proxy_ip)) { -
LOL (Sorry to be overly blunt, but like part of my signature states, knowing enough of the language being used is a prerequisite.) Somewhere in your code there are a couple of lines of code like this - $something = new File(); $something->dir = "/services/webpages/util/b/o/borissamarov.site.aplus.net/public/i/exhibitions/"; $something may in fact be any variable name, the two lines of code won't necessarily be together, and the /services/webpages.... value may in fact not be that whole string (depending on what amount of the information from the error is in $this->dir and what amount is in $this->name) or can be composed of more than one thing, including but not limited to quoted strings, other variables, or defined constants... Do you have a programming editor, like notepad++ (not to be confused with MS notepad) that would allow you to globally search at one time through all the files in all the folders that make up your application to find where either the relevant code is at or to find where the current setting is located?
-
Talk about pulling teeth to get information to use to help Best guess on this one is that the variable $this->dir contains the intended target directory where the uploaded files are supposed to be copied to. You would need to locate the code that is setting $this->dir and change it to point to the directory on the new server where you intend your uploaded files to be copied to.
-
I wonder where on the php.net site you found your php, because php 5.2.12 and 5.3 are the latest versions. Edit: Php 5.0.0 was released a really long time ago - 13-Jul-2004
-
What does a phpinfo(); statement show for the php version and the mysql client library version information? The mysql client is the client library that php is using to connect with the mysql server. The error you are getting is usually caused when you are using an older version of php (and the client library files that come with it) with a newer version of mysql. @J-C, his issue is not enabling the extension, it is getting an error when using that extension to connect to the mysql server.
-
Naming a mysql in php using a forms post value
PFMaBiSmAd replied to phpserver's topic in PHP Coding Help
And actually as soon as you put any code into one of your files and attempt to execute it on your server, it becomes your code. You are responsible at that point for at least stating what symptom you see in front of you when you try it, because as has already been pointed out, telling someone that code does not work is useless information. -
Access denied for user 'ODBC'@'localhost'
PFMaBiSmAd replied to WWW_9hub_Net's topic in Third Party Scripts
The following is the offending code from the header.php file (and I do mean that script contains some offensive programming) - // grab the connecting IP address. // $connecting_ip = get_ipaddress(); if (empty($connecting_ip)) { return FALSE; } That return statement causes the code in the included file to abort and continue execution in the main script. This skips making the connection to the database and the creation of the $dbexists variable, but no errors are reported or outputted as to why the script took this action. Whatever get_ipaddress() does (it is probably defined in the functions.php file) does not work when you access the script from a non-local address (I suspect is it checking optional headers that simply don't exist.) That script looks like it was written by someone who got a C- grade in a programming class. Edit: Is that the person who wrote this code? Because while the comment about the proxy might be relavant to the problem (depedning on how badly coded the get_ipaddress() function is), the suggested solution of using SSL/https has absolutely no relevance. -
PHP if statement not registering, or something.
PFMaBiSmAd replied to Cultureshock's topic in PHP Coding Help
There's nothing logically wrong with the code. It is more likely that index.php contains an error that is causing you to think that the login code took an incorrect execution path. Have you commented out the two header() redirects and put in echo statement of something so that you know for a fact which execution path the code is taking and it would take seeing your index.php in order to determine if it is responsible for the symptom. You also don't have a session_start() statement in the posted code, so if the overall symptom is your log in form being redisplayed, then it is likely due to the $_SESSION variables not existing outside of the posted code. -
The third error is actually due to the output of the first two error messages and should go away once they are fixed.
-
Too bad the author did not publish any information or host a forum on the sourceforge site. Have you checked his direct site, which unfortunately is not in English. Short version of what it is doing - The script uses AJAX in the browser to submit to an iframe. This allows the status to be fetched from the server and updated on the page while the upload is in progress. This is pretty standard for doing things like displaying an upload 'activity' (not to be confused with upload progress) indicator and for displaying upload error messages. What the code is doing differently that allows the upload progress to work, is it starts a php script that opens a socket connection that listens on a specific (randomly picked) port number. There is also a process id number assigned. The port number and process id are passed back to the javascript running in the browser. The browser submits the form data to the correct port number so that the php script is actually used to receive and process the uploaded data. The javascript code that gets and displays the progress is again using AJAX and periodically makes http requests to the getinfo.php page, providing the specific process id on the end of the URL. This page uses the specific process id to get information about the matching file being uploaded and returns that information to the browser where it can be displayed. Do you have a more specific question that was not answered already?
-
My code, could someone look this over and comment
PFMaBiSmAd replied to djdubuque's topic in PHP Coding Help
The name of your form field (call_sign) is not the name you are using in the php code (call). And this is not actually a mysql query issue (the point in the code where the query is at is not even being reached), so moving this thread to the php help forum. -
Because it is just an example of how to do something and it is expected that it may need to be adapted it to fit any specific use you may have.
-
And assuming the file will always fit into memory, try this simple solution - <?php $the_file = 'text.dat'; // what file to read $lines = file($the_file); // read the file into an array // example 1 $find_these = array(1); // the line(s) you want foreach($find_these as $key){ $index = $key -1; // adjust to match actual index values (start at zero) echo "Line: $key, $lines[$index]<br />"; } // example 2 $find_these = array(1,2,3); // the line(s) you want foreach($find_these as $key){ $index = $key -1; // adjust to match actual index values (start at zero) echo "Line: $key, $lines[$index]<br />"; } ?>
-
The answer depends on if the maximum size of the file can grow so that it will not entirely fit in available memory at one time?