-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
The mysqli api doesn't really lend itself well to wrapping things up in functions. After thinking about it for a bit this seems to work, but I did very limited testing and there may be problems with more advanced queries or usages. <?php function mysqli_streamlined_query($link, $sql, $params, &$row){ $stmt = mysqli_prepare($link, $sql); if (!$stmt){ throw new Exception('Unable to prepare query '.$sql); } if (($pcnt = count($params)) > 0){ $columnSpec = str_repeat('s', $pcnt); $bindParams=array($stmt, $columnSpec); foreach ($params as &$p){ $bindParams[] =& $p; } $ret = call_user_func_array('mysqli_stmt_bind_param', $bindParams); if (!$ret){ throw new Exception('Unable to bind query parameters: '.print_r($params, true)); } } if (!mysqli_stmt_execute($stmt)){ throw new Exception('Unable to execute query'); } $meta = mysqli_stmt_result_metadata($stmt); if (!$meta){ throw new Exception('Unable to get result metadata'); } $fields = mysqli_fetch_fields($meta); if (!$fields){ throw new Exception('Unable to get result field list.'); } $bindResults = array($stmt); foreach ($fields as $f){ $row[$f->name] = null; $bindResults[] =& $row[$f->name]; } $ret = call_user_func_array('mysqli_stmt_bind_result', $bindResults); if (!$ret){ throw new Exception('Unable to bind result variables.'); } return $stmt; } Example usage: <?php require_once 'mysqli_streamlined_query.inc.php'; $dbc = mysqli_connect('127.0.0.1', 'user', 'pass', 'db'); $sql = ' SELECT uid, email, firstName, lastName, lastLogin FROM table_users WHERE uid=? '; $params = array(67); $row = array(); $stmt = mysqli_streamlined_query($dbc, $sql, $params, $row); while (mysqli_stmt_fetch($stmt)){ var_dump($row); }
-
So long as your have an A record somewhere that allows mydomain.com to resolve to an IP you should be fine. The glue records should suffice.
-
As far as I know, yes that should be fine.
-
If there is no MX record, SMTP servers will fallback on the A record for the domain and attempt to deliver to that IP. You should have an MX record if your accepting mail though, and it should point to whatever your mail server's host name is, and that host name must have an A record to resolve it's IP address. Transaction sort of goes like this: mail to you@mydomain.com: - server queries MX records for mydomain.com. Receives back a list of hostnames, in your case mail.mydomain.com - server queries A record for mail.mydomain.com. If an IP is received, connect to that IP and deliver the mail - if it fails to connect, it tries the next server in the MX list (sorted by the preference). - if all mx servers fail (or no mx record) it will query an A record for mydomain.com and try to deliver the mail to there.
-
I don't see a reason to have an MX record at all if there is no server that accepts mail for your domain. If your not accepting mail, then you should fail an MX check.
-
I just checked it out. I do like the look and feel, but it is lacking a lot of functionality that makes things like firebug of chrome dev tools useful. Perhaps it will get better after another version or two. I never really did like the way firebug worked, I always found it to be clunkly and a pain. Chrome's dev tools I found to be pretty user friendly. I've done almost all my dev work in chrome over the last two years. I will do some functionality checks in firefox and IE after the pages are mostly ready to go. For what I do (fairly basic stuff) the browsers all seem to work the same these days and I have had few issues. It's nice that things seem to be getting better with that respect.
-
You need an A record for your mail.mydomain.com otherwise the mail servers on the web wouldn't know how to contact your mail server because they wouldn't know it's IP address.
-
You would just have to configure your web server such that if someone went to that domain it would redirect them to your main domain instead. I wouldn't worry about it too much, so long as your not linking or advertising your mail.mydomain.com around the internet nobody should really be using it when trying to surf to your site.
-
sprintf may be a good function for this. Example: sprintf("%c%10s ", $firstChar, $digitString); You would set $firstChar to G or N based on whatever criteria controls that. $digitString is the 10 digit number. The format code should pad it with space if it is less than 10 digits. Then three spaces to fill out to char 14. You don't say what would go in the slot held by 15-77 so I stopped there but depending on the rules you may be able to insert them with other format codes.
-
Remote Connection "Network Issues"?¿? SQL Server 2008
kicken replied to powpow's topic in Microsoft SQL - MSSQL
The error shown in your attached image would lead me to believe that your server instance is not accepting connections over TCP/IP. You should check the server configuration to see if it is allowing tcp/ip. As a quick check you could look at the output of the netstat -nap tcp command and see if there is anything listening on port 1433. As for your login failure, make sure the username and password are correct of course, and make sure they have been setup in the server's security settings for a DB. -
You can use a tool like dig to query dns servers for the information. You could use it to query your nameserver directly (the one with the zone file) to ensure it returns the correct information. You may also be able to see how much time remains before the server your querying updates it's cache. For example, if I query my domain: kicken@bonzi:~$ dig MX aoeex.com [..snip..] ;; ANSWER SECTION: aoeex.com. 3600 IN MX 0 sitemail.everyone.net. The 3600 is the TTL value meaning that server will serve that response for 3600 seconds before it updates it by checking the master server again. Essentially, it is now cached for the next hour.
-
Things like this is why it is a poor idea to try and determine which browser a person is using. It's far better to try and determine if the features you want are implemented and ignore which browser it is. For example if you want to use WebSockets if available, you'd do something like: if (typeof WebSocket !== 'undefined'){ //websockets are available. } rather than try and determine if the browser is chrome or whatever other ones support it now. As support grows in other browsers, your code will just start working with no need for you to do anything.
-
PHP shows the sqlsrv drivers, but I can't connect to MS-SQL
kicken replied to sql-lover's topic in Microsoft SQL - MSSQL
FormatErrors is not any standard function. Not sure where you got that name from. To see what the error is, try var_dump(sqlsrv_errors()); -
Nice, thanks. Just noticed something had changed when I posted in another thread. Hopefully I can live up to the title
-
Aye, I did that after a couple days in mine. I save the previous user id in a key in the session. on logout if that key is there it restores the previous user session. Saves a lot of time.
-
You use == to compare. = is an assignment. You also need to enclose the whole condition in parenthesis: elseif (($md_date_string=="") && ($other_name_string != "")) {
-
Then I guess you best stop using it, because facebook does infact do this
-
I've developed a few different applications where such a feature is also a standard thing for top-level administrators. I call it impersonation and when they go to a user's account details there is a link to impersonate them. Essentially is just replaces the current session with a session populated with that users details. The feature is intended mainly to be able to view things as that user for debugging purposes. If users report a problem that cannot be reproduced with an admin account (or our test users) we will impersonate them, re-create it (on a development environment of course, not live) and work toward a fix. In really is an invaluable feature to have. As for any concerns, it's not like it would be that much harder for someone at said site to just look into their database and view all your activity or whatever else your afraid this impersonation feature might allow someone to do. On our setups at least, only people who have access to the database also have access to the impersonate feature. Mainly developers and a couple IT managers. Regular staff are not permitted to use it, any problem they come across that might require it has to be forwarded up the chain. edit: The main reason it was implemented (besides it's obvious usefulness) is because without it when users would have problems, it was a problem that some people were just asking for their username and password so they could login as the user. It's far better to let a staffer login as a user without knowing what their password actually is. Even though that ability is restricted, it has still helped with that problem considerably.
-
Any value that can be serialized can be stored. Arrays, strings, numbers, other basic data types are fine. Most objects can also be serialized, but sometimes it can cause problems. Best to test any object types to ensure they work. Resource types are generally not capable of being serialized and thus cannot be saved in a session. Note that PHP will not prevent you from attempting to store any type into the session array. The values will just not be successfully saved and restored when moving to a different page.
-
If you want to have a remote file with the details, it will have to be encrypted and then decrypted by your app after download. The method you use to download it (curl vs allow_url_fopen) makes no difference, as both are just a simple http request. IMO, your probably better off just embedding it into the source directly.
-
<? echo ($info['Status'] == 'Sold' || $info['Status'] == 'on hold') ? "<span class='echo'>".$info['Status']."</span>" :"For sale"; ?> You have to repeat the variable, you can't just do two values separated by a ||. If you need more values, it may be more beneficial to use an array of values and the in_array function.
-
Am trying to get a program working where the user can upload a file...
kicken replied to APD1993's topic in PHP Coding Help
That means your posting to the wrong URL. You need to make sure your posting to your PHP file. Your code that you posted is ment to be on the receiving end of your upload. Your form should have it's action set to the url of that page. -
Am trying to get a program working where the user can upload a file...
kicken replied to APD1993's topic in PHP Coding Help
Which is? What does var_dump($_FILES); show? What about var_dump(is_writable('C:\xampp\htdocs')); ? -
Am trying to get a program working where the user can upload a file...
kicken replied to APD1993's topic in PHP Coding Help
So long as C:\xampp\htdocs\ exists and is writable by the server it should copy ok. Do you get warnings or is the file just not showing up? Does it upload successfully?