-
Problems with config.php for a script.
Date: 01/28/07
Keywords: php, html
Okay, well this is my first time posting to this community, I've little experience with php so I'm working off of pre made scripts. I rrecieved this problem:
Warning: main(/home2/yukapok/data/lib/cache/lib.php) [function.main]: failed to open stream: No such file or directory in /home2/yukapok/public_html/candy/includes.php on line 25
Fatal error: main() [function.require]: Failed opening required '/home2/yukapok/data/lib/cache/lib.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home2/yukapok/public_html/candy/includes.php on line 25
So, line 25 is: require_once($CFG->dirroot.'lib/cache/lib.php');
Ask for more information and I'll edit it in. Thanks, I hope I get this figured out...
Source: http://community.livejournal.com/php/534236.html
-
mysql connection pooling per script execution
Date: 01/28/07
Keywords: php, mysql, asp, sql
I try not to be authoritive on anything until I got documentation to back me up and at the last minute of work on Friday I ran into a problem. One of the core programmers in my team is a recovering .net/asp developer who is still getting upto speed on PHP. He's got the block and tackle idea's but of course you can't become a master at a new language until you've had atleast one or two nervous breakdowns because the new language isn't doing what the other languages did. thedailywtf.com also helps.
Anyway: to the point. My understanding of the mysql library in PHP core is that it tries it's best to recycle instances to the server between different instances. So if script A is run by 10+ different people, php mysql is going to try and share. Apparently this is not true in .net (version unknown). My coworker got called in to fix a wtf script that would slowly devour all available connections to the DB because the last developer didn't close the connections. So he wrote this really amazing and really elaborate wrapper class that I don't think is necessary but I am not completely sure.
Basically, on wrapper creation, it checks a flag for "in_use" and if true, creates a new mysql_connect resource handle. This scares me because if I really understand it... the wrapper could create a dozen handles to the DB in one cycle of script execution then multiply that by number of individual script executions and this could be bad? Or am I wrong. Is the php mysql_ smart enough not to shoot us in the foot?
The original plan was for the DB wrapper to be used like so.
FrameworkObject->getDb("db name");
this then skims through an array structured like:
$dbc['db name'] = array('info'=>'This is the general db connection', 'server'=>'my.server.com', 'account'=>'myUserName','password'=>'pw','flags'=>NULL,'INT'=>NULL);
The key is the $dbc['db name']['INT'] which would hold the resource handle to the wrapper. Voila, instant conservation of resource handles. Then the trick is just to put in the DB::__destruct() a mysql_close();
Or am I wrong as well? or are we both wrong in ways not understood just yet?
Source: http://community.livejournal.com/php/533911.html
-
__autoload() function
Date: 01/26/07
Keywords: php
Had some downtime at work today. Figured well, let me edumacate myself a bit. Learned about the __autoload() function in PHP 5.
I keep all my classes in one dir "classes" or sometimes a subdirectory thereof so this function fits like a glove and is now going to be a permanent resident in my config.php file!!!
Bored? It pays to browse php.net during downtime.
Source: http://community.livejournal.com/php/533667.html
-
Regex fun - nested "tags". (x-posted to linux)
Date: 01/25/07
Keywords: php, web
I am still learning Regex's so doing crafted complicated patterns is just a little bit out of my reach.
What I am trying to do:
Messing around with different output handling schemes for a webscript. The logic I am using is that at the end output would be broken down into blocks. So inner most tags would all be appended to a buffer of that tagName. So at the end of script execution I might have 2+ buffers of names like system,application,template, etc that I can then handle. One of the justifications for investing time in this is to come up with some sort of sectionized caching system (so everything is rendered previously except say 1 small section). Otherwise if regex can't do this fast enough, another thought was to "improve" the PHP output buffering system.
What I got: '(?:%OB_(?P[A-Z]*)%\n?(?P.*)\n?%/OB_\1%)'
Mode: Single-Line
Engine: PHP/PRCE
Test data:
%OB_SYS%
System started: 0492
Good to go!
%OB_APP%
This is a test
%OB_TEMP%
Hello world!
This
is
a
test
%/OB_TEMP%
%/OB_APP%
System closing up
%/OB_SYS%
Source: http://community.livejournal.com/php/533258.html
-
refresh
Date: 01/23/07
Keywords: php
Does anyone know a way to tell if the current window has been refreshed using PHP?
Source: http://community.livejournal.com/php/533157.html
-
DbSimple: need your opinion
Date: 01/23/07
Keywords: php, mysql, sql, postgresql
Recently I translated into English one of my old project, DbSimple (LGPL). It is a DB abstraction library for PHP which could work with MySQL, PostgreSQL, FireBird. The main idea is extremely simple interface: everything which may be done automatically is realized so in DbSimple, and code remains quite readable.
It would be great if your comment this library (and possibly try). For my projects this library simplifies the work very much, maybe it will be useful for others...
Some key features:
- Conditional macro-blocks in SQL body ({}-blocks), which allow to dynamically generate even very complex queries without detriment to code readability.
- Caching of query results (if necessary).
- Different fetch methods (as column, as 2d array, as key-based multidimension array, as tree etc.).
- Supports various placeholder (query arguments) types: list-based, associative, identifier-based etc.
- Supports operation "select + count total number of resulting rows" (for data displayed page-by-page).
- Functions for direct fetching: all result rows, one row, one column, one cell, associative array, multi-dimensional associative array, linked tree etc.
The most interesting synopse (macro-blocks, placeholders, select one page with total counting):
$rows = $DB->selectPage($totalNumberOfRows, '
SELECT *
FROM goods
WHERE
category_id IN(?a)
{ AND activated_at > ? }
LIMIT ?d, ?d
',
$categoryIds,
(empty($_POST['activated_at'])? DBSIMPLE_SKIP : $_POST['activated_at']),
$pageOffset, $pageSize
);
Other synopsis are at http://en.dklab.ru/lib/DbSimple/#list1
Source: http://community.livejournal.com/php/532896.html
-
PHP w/Eclipse
Date: 01/21/07
Keywords: php
Debating renewing my license with Komodo... I really do like Komodo and the 4.0 beta fixes a lot of things I didn't like about it, but it's always worth experimenting and I like a lot of the plugins for Eclipse (subclipse, aptana, and the built in tools).
That said, has anyone used or continue to use one of the PHP plugins for Eclipse? I remember there were 2 of them... one of which I really didn't like and the other I never tried. I am looking for something that works with xdebug and has semi-intelligence code lookup + any other nice tools.
Source: http://community.livejournal.com/php/532527.html
-
ADOdb (Lite) Error Reporting
Date: 01/21/07
Keywords: browser
I recently completely integrated ADOdb into a site I am running and am looking for suggestions on how to report errors, either straight to the browser, via email, dumped into a log file (or all three).
Any ideas or suggestions?
Source: http://community.livejournal.com/php/532349.html
-
Troubles with cookies
Date: 01/19/07
Keywords: php
I'm having trouble setting up some cookies. It is a login form with a "remember me" option. If the user checks the "remember me" box, a cookie is set. If not, only session values are set.
The problem the cookie is not being sent. This is my code ($info is the array holding the user information):
if ($_POST['remember'] == 1) {
$cookie_domain = "config set cookie_domain";
$cookie_time = time()+60*60*24*365;
setcookie("user_num_id", $info['id'], $cookie_time, "/", $cookie_domain);
setcookie("user_id", $info['user_id'], $cookie_time, "/", $cookie_domain);
setcookie("name", $info['name'], $cookie_time, "/", $cookie_domain);
setcookie("remember", 1, $cookie_time, "/", $cookie_domain);
}
$_SESSION['user_num_id'] = $info['id'];
$_SESSION['user_id'] = $info['user_id'];
$_SESSION['name'] = $info['name'];
$_SESSION['uid'] = session_id();
$_SESSION['auth'] = 1;
Header("Location: account.php");
I suppose is some kind of header problem because, if I delete the "header" line, the cookie is set. This is meant to redirect the user to the account page after login. Anyone has a idea of why this isn't working? Thanks!
Source: http://community.livejournal.com/php/532165.html
-
Array for checkboxes?
Date: 01/18/07
Keywords: no keywords
Hi everyone,
Quick question: is there an array made, or a way I could quickly reference an array of the checkbox elements in a single form? I have like 200 checkboxes I need to aggregate into a query string for insertion and really don't want to have to do the make array then list all of the $_POST values thing...
Thanks!
Source: http://community.livejournal.com/php/531855.html
-
Help w/ arrays
Date: 01/18/07
Keywords: php
I need to take this
Array
(
[ccurry] => Array
(
[CCR] => ccurry
)
[shaywood] => Array
(
[CCR] => shaywood
)
[lrichmond] => Array
(
[CCR] => lrichmond
)
[tlambeth] => Array
(
[CCR] => tlambeth
)
[lgrant] => Array
(
[CCR] => lgrant
)
[bhudson] => Array
(
[CCR] => bhudson
)
[lscott] => Array
(
[CCR] => lscott
)
)
And get an array of just the usernames out of it. Is there a php function to do this or do I need a loop or what?
Source: http://community.livejournal.com/php/531676.html
-
Fork a process on Windows (php)
Date: 01/18/07
Keywords: php, mysql, sql
I have two scripts: The first checks adirectory for data files several times an hour. If data files arefound, a second script is called to process each data file. The secondscript is time intensive and if there are multiple files to process I'msure to encounter timeout issues (and I don't want to increase my phptimeout to unreasonable levels)
(fwiw, the second script does not involve repeated MySQL queries (onlyone read per file), it's just text parsing but there is a LOT of text.Perl is not an option at this point. I'm using ereg instead of thebuilt-in php str functions to help ease the load on the cpu).
So -- is there a way to fork (or spawn) a new php process in a windows environment?
Many thanks,
pk
Source: http://community.livejournal.com/php/531237.html
-
newbie!!!
Date: 01/18/07
Keywords: php, programming, mysql, sql
hih guys!!!
I'm new here ^_^ I have been programming in php for about 2 years. I also post some php / mysql snippets in my journal when i freak out hehehe.
Hope to have a good time with you guys ;-)
Source: http://community.livejournal.com/php/530977.html
-
losing my patience...
Date: 01/17/07
Keywords: php, mysql, sql, web
edit: solved. thanks for noticing my oversight... doh.
Thanks in advance for any help. This is a probably a simple one but here goes:
I have this part of a script that doesn't wish to behave:
the db connection is in place, and when i echo back the query to the web page and copy and paste it into phpMyAdmin, the query works fine and returns my result. There should only be one row of results, which there is when I run the query, but when I try to fetch the result and store it in the variable $prefix it doesn't work. I'm not getting any errors thrown, it's just not working. Any ideas? Sorry if it's totally obvious. I'm under a zillion deadlines and have spent too long swearing at the computer over this one.
Thanks again!
Source: http://community.livejournal.com/php/530760.html
-
login help
Date: 01/17/07
Keywords: php, mysql, html, database, sql
I'm trying to create a super basic login page.. one that doesn't require a mysql database of usernames and passwords, which apparently is nearly impossible to find. I'm still relatively new to php.. bumbling along mostly. Anyway.. here's what I've got so far
In the first page of the protected section:
session_start();
if (isset($_POST['user'])) {
$_SESSION['username'] = $_POST['user'];
$_SESSION['password'] = $_POST['pass'];
$_SESSION['authuser'] = 0;
}
//check username and password information
if (($_SESSION['username'] == 'bob') and
($_SESSION['password'] == 'smith')) {
$_SESSION['authuser'] = 1;
} else {
echo "Sorry, but you don't have permission to view this page, Try Again";
exit();
}
?>
What I'm trying to accomplish is being able to kill this information with a "Logout" button. I've attempted putting session_destroy() and session_unset(); in the header of that page.. tried resetting the $_POST['user'] to nothing or something other than 'bob' (and changing the isset part.)
Nothing works.. I'm still passing something that's allowing me to be logged in.
How can I code this so it's totally killed.. dead, gone.. when they hit a button that says logout ??
for the rest of the pages can I simply put in the header
session_start();
if ($_SESSION['authuser'] = 1) {
?>
html stuffs
else {
echo "Sorry, but you don't have permission to view this page, Try Again";
exit();
}
?>
you guys are my last hope.. I'm about to toss the whole thing and resort to .htaccess .. please help!
ETA: Problem appears to be fixed.. thanks everyone!
Source: http://community.livejournal.com/php/530638.html
-
beginner's question...
Date: 01/16/07
Keywords: php, mysql, sql
Okay, I'm new to php and am trying to set up a php/mysql calendar. I've got it all up and running but now I've got to tweek it based on my audience, so instead of it listing months and dates in English it needs to show them in both English AND Spanish, so I'm looking for some (hopefully) simple code help.
Here's a pic of part of my current code:
It's showing everything in Spanish perfectly, but I can't get it to show both. Basically what I want it to do is:
if current month is 01 then current month is Enero - January
...but any time I add "- January" or just a space and then January my code errors out or just shows a 0. Is there anything special I need to do for it to show Enero - January or Enero January?
I'm sure it's something simple that I've overlooked or forgotten.
Thanks in advance!!
Source: http://community.livejournal.com/php/530196.html
-
UK webhosting recs ?
Date: 01/16/07
Keywords: php, mysql, database, sql, web, linux, hosting, apache
Can anyone recommend any reliable and not too expensive UK based webhosting companies?
(only hosting, no domain name registration needed)
Necessary features:
- Linux/Apache server
- at least 150MB webspace
- bandwith/traffic on a normal scale, the more the better *g*
- PHP (version 4 okay, 5 better)
- at least one MySQL database
- FTP access and several email accounts should be a given
A plus, but not really neccessary:
- .htaccess
- cgi/perl
- shell access
ETA: Is DreamHost a recommendable webhost for a small business website?
I do have a DreamHost account, mostly for dabbling around and trying out stuff, and love all their features (and low prices). But although I've never had any problems so far, hearing every now and then about down times or bad customer service makes me a bit reluctant to recommend them to a client for hosting their small business website. Opinions, anyone?
Thanks! :-)
Source: http://community.livejournal.com/php/530162.html
-
Project management
Date: 01/15/07
Keywords: no keywords
Looking for anyone's experience in coming up with some sort of deployment system to bring together 4 different programmers on a project that needs to be built rapidly.
I am pretty well versed in subversion, but the way the lead of my new company is explaining, the individual developers will need to be able to modify the site's core library at will. And the concern with this is, what if one developer breaks a needed component...suddenly the other 3 programmers are at a work stoppage until it's fixed. So he suggested creating 4 branches of the main repository for the other dev's and me. This way each Dev has their own code base to modify at will. This seems a little crazy, but maybe I am missing something here.
From my understanding, you can remerge different branches together...but to do so requires manually walking through diff's of conflicting revisioned files. So unless we merge all 4 branches on a weekly basis, this will be one massive cluster -ck eventually at the end.
Some quick thoughts on my own:
Dedicating one of the 3 programmers to developing the core library, basically giving him/her a "I need this functionality" memo or something.
Coming up with some sort of per-file branching scheme when a dev has to edit a library/base system.
Any comments or suggestions would be greatly appreciated.
Source: http://community.livejournal.com/php/529796.html
-
Method name must be a string.
Date: 01/14/07
Keywords: php, browser, web
I have a weird thing happening in one of my scripts. A statements that looks like this:
$this->updateFooBar('BarFoo', null, null, NOTIF_TYPE_CHANGE);
Gives the following result in the browser:
Fatal error: Method name must be a string in /usr/local/web/a/b/c/d/MyFile.class.php on line 141
My first guess was that I've accidentally define()d updateFooBar, but I haven't. It's a class method inherited from the parent class. Any ideas?
Source: http://community.livejournal.com/php/529537.html
-
Help with creating an Administrator page.
Date: 01/12/07
Keywords: php, mysql, database, sql, web
Hello! This is my first post on LiveJournal.
I'm making a website for the group that I'm in, and I have a little bit of self-taught PHP & MySQL experience, but I'm up to the point of making the administration section so we can update the site without any hassle.
All I need is a little bit of a push to start me rolling (so to speak)
Any help is appreciated and will get a spot in the credits for the site.
What I need is:
*Admin Login.
*Posting Support.
*Managing of posts.
*Page authoring (eg... projects.php?id=XX (where 'XX' is projects name)).
*News authoring.
(MUST INCORPORATE MYSQL DATABASE!)
Any little bit of code would be great, just as long as it gets me started!
Thank you!
Source: http://community.livejournal.com/php/529282.html