-
Question about Arrays
Date: 12/31/09
Keywords: no keywords
Hi guys, another dumb question!
Do things like in_array and array_search work properly in multi-dimensional arrays? Also, is there a way to specify which elements in a multidimensional array to check?
Thanks!
Source: https://php.livejournal.com/675394.html
-
poorly formed JSON - options?
Date: 12/14/09
Keywords: no keywords
Hello everyone!
For a project I'm working on, I'm writing a screen scraper. Unfortunately the material I am attempting to mine is poorly-formed JSON (probably parsed with proprietary code). json_decode() returns NULL.
My first thought was that I'd just parse it with regular expressions. Here I've run into a question I can't seem to work out. Much of the data I'm trying to parse looks like
name:'blah blah blah'
So I thought perhaps I could use
/name:\'([^'.*]*)\'/
to grab the stuff between single quotes.
Unfortunately some of the data has escaped single quotes inside, like this:
name:'blah\'s blah blah'
in which case my regex returns only "blah\".
So is there a way to say in regex speak, "stop at the next single quote, unless it is escaped with a slash?" I've not been able to find any reference to a way to write a regex which has an exception to a character negation.
As an alternative, I'm wondering if maybe there's something like Tidy, but for JSON. So far I'm not finding much.
Thanks!
ETA: After much trial and error I found a solution:
name:\'([^']+\\\'[^']+)\'|name:\'([^']*)\'
But I'd still be curious to learn if there's a program like Tidy for JSON.
Source: http://php.livejournal.com/675088.html
-
poorly formed JSON - options?
Date: 12/14/09
Keywords: no keywords
Hello everyone!
For a project I'm working on, I'm writing a screen scraper. Unfortunately the material I am attempting to mine is poorly-formed JSON (probably parsed with proprietary code). json_decode() returns NULL.
My first thought was that I'd just parse it with regular expressions. Here I've run into a question I can't seem to work out. Much of the data I'm trying to parse looks like
name:'blah blah blah'
So I thought perhaps I could use
/name:\'([^'.*]*)\'/
to grab the stuff between single quotes.
Unfortunately some of the data has escaped single quotes inside, like this:
name:'blah\'s blah blah'
in which case my regex returns only "blah\".
So is there a way to say in regex speak, "stop at the next single quote, unless it is escaped with a slash?" I've not been able to find any reference to a way to write a regex which has an exception to a character negation.
As an alternative, I'm wondering if maybe there's something like Tidy, but for JSON. So far I'm not finding much.
Thanks!
ETA: After much trial and error I found a solution:
name:\'([^']+\\\'[^']+)\'|name:\'([^']*)\'
But I'd still be curious to learn if there's a program like Tidy for JSON.
Source: https://php.livejournal.com/675088.html
-
Database Connections
Date: 12/04/09
Keywords: database
Hi Guys!
Another dumb question from the peanut gallery!
If you're writing a bunch of classes that will run an application, where is the best place to have your database connection(s)? Would it be in the file that ends up interfacing with the user and receiving/displaying data, in the class files themselves, or some other location?
Thanks!
Edit: If the answer is in the calling files, how would you make sure your classes used it, and how would you pass it across pageclicks?
Source: http://php.livejournal.com/674926.html
-
Database Connections
Date: 12/04/09
Keywords: database
Hi Guys!
Another dumb question from the peanut gallery!
If you're writing a bunch of classes that will run an application, where is the best place to have your database connection(s)? Would it be in the file that ends up interfacing with the user and receiving/displaying data, in the class files themselves, or some other location?
Thanks!
Edit: If the answer is in the calling files, how would you make sure your classes used it, and how would you pass it across pageclicks?
Source: https://php.livejournal.com/674926.html
-
finding code
Date: 12/02/09
Keywords: cms, google
Hi,
I am adding a search engine to a CMS I built. I want the results to come out like on google or wikipedia, with the relevant parts of the page highlighted.
I know this has been written and implemented so many times,
but on a preliminary search I realised I must be bad at finding shared code.
Can any one suggest a quick way to find shared code?
Source: http://php.livejournal.com/674573.html
-
finding code
Date: 12/02/09
Keywords: cms, google
Hi,
I am adding a search engine to a CMS I built. I want the results to come out like on google or wikipedia, with the relevant parts of the page highlighted.
I know this has been written and implemented so many times,
but on a preliminary search I realised I must be bad at finding shared code.
Can any one suggest a quick way to find shared code?
Source: https://php.livejournal.com/674573.html
-
PHP and JavaScript
Date: 11/30/09
Keywords: php, java
Hi Guys!
Another super dumb question on the way!
Is it possible to assign a PHP variable a value within a javascript function?
For example I've got a text box showing up only when a certain tickbox is ticked. I'm using javascript to show/hide the text box. When that box is ticked, I want the PHP variable $classes to have a different value.
Should I send this to a JavaScript community instead?
Thanks!
Source: http://php.livejournal.com/674465.html
-
PHP and JavaScript
Date: 11/30/09
Keywords: php, java
Hi Guys!
Another super dumb question on the way!
Is it possible to assign a PHP variable a value within a javascript function?
For example I've got a text box showing up only when a certain tickbox is ticked. I'm using javascript to show/hide the text box. When that box is ticked, I want the PHP variable $classes to have a different value.
Should I send this to a JavaScript community instead?
Thanks!
Source: https://php.livejournal.com/674465.html
-
Do x to items 1-7, then y to items 8 on?
Date: 11/30/09
Keywords: php, css, java
Hi, I am tearing my hair out over this one feature I have on a site I'm building. I've got it working just about great, with one little hitch. I won't bore you with the details, but essentially:
I have a piece of PHP that produces a list of images.
These images are presented within a javascript/CSS scroller.
In order for the scroller to have the correct layout, from the 8th image on needs to also have a class tag of 'hide' (so you only see the 1st 7, unless you use the scroll button to scroll through them all).
So I am wondering if there is a way to change the code so that the first 7 or fewer images do NOT get the 'hide' tag, and all the rest do.
Any suggestions you can give me would be awesome. Thanks in advance!
Source: https://php.livejournal.com/674277.html
-
Simple things can be hard. :(
Date: 03/13/09
Keywords: browser, css, html
Hello everyone.
I've posted here before but now I'm looking for advice on css/html. I know it's somewhat off-topic.. but /shrug, I've spent all day at work kicking myself over this.
So I have this page I need to develop. I'm pretty pro at css/html but for some reason, my life hates me today and it's either breaking in firefox or IE.
This is what I'm getting in my browsers:
Firefox 3.0.7
IE 7
IE 7's screenshot is what I want. Firefox is just being way off. But anyways, I was wondering if anyone had any tips on how I can get this to work in both browsers.
Just for your reference, here is the my code:
http://binarychick.net/hostedfiles/ent-cal/source.txt
Help is appreciated. Thanks in advance.
Source: http://community.livejournal.com/php/659672.html
-
Free website magazine
Date: 03/11/09
Keywords: web
Free website magazine TO QUALIFY FOR A FREE SUBSCRIPTION, YOU (or your company) MUST HAVE AN ACTIVE WEB SITE.
Source: http://community.livejournal.com/php/659417.html
-
php driven image gallery - help needed
Date: 03/10/09
Keywords: php, mysql, database, sql, web
(x-posted to php_dev)
Hey guys,
I'm coding an image gallery to use on my PHP site and need a bit of help with a couple of features I want to code into it. I was hoping someone here could either give me some pointers or send me to a website that will help with either explainations or code snippets :)
1. Firstly, thumbnails. I have created an admin panel where I upload the images and can set various things like the category, title etc, and all that is stored in a MySql database, and the file uploaded to a general directory. But i'd also like to create a thumbnail of the image as it uploads. I've found several scripts that make thumbnails from images already in a directory, but i'd like it to happen as I upload the image. Is that possible? Without having to use some all-in-one image gallery script heh. I'd also need it to resize the image proportionally so that images aren't just squashed into a 100x100 square shape.
2. Secondly, I'd like to "tag" images like with LJ entries, so that on the front end when a picture is being viewed, the list of tags is shown and can be clicked on to show other image thumbnails with the same tag. But i'm not really sure how to go about this... I was just going to have a table field called img_tags and store them all in that per image, but then is that efficient? searching for matches within a db field? any tips or suggestions?
3. oh and as an extra thought, how can i then take those tags and make a tag cloud maybe?
All and any help would be most appreciated! :)
paul
x
Source: http://community.livejournal.com/php/659077.html
-
When to seperate tables?
Date: 03/02/09
Keywords: no keywords
I currently store
User Info
Passwords
Group associations
All in the same table
Should I be storing them separately?
I was thinking about this as I considered allowing user to change their passwords. My train of thought was that it might be more secure to keep it all separate in this instance.
?
Source: http://community.livejournal.com/php/658915.html
-
Using XAMPP on Vista
Date: 03/01/09
Keywords: security, apache
Hi dear all,
Sorry for bothering you. I am using Windows Vista. I cant seem to start the Apache service.
Does anyone know what might be causing it? I have a feeling, it may be some security issue.
Source: http://community.livejournal.com/php/658673.html
-
Help?
Date: 02/23/09
Keywords: web
Anyone want to help me with my code?
It doesn't seem to be centering my layout properly.
I want it aligned in the center no matter how I open or size the page. center left to right, and top and bottom.
if anyone can help me, let me know.
my email is krzenet@gmail.com
my website is krze.net
Source: http://community.livejournal.com/php/658421.html
-
[tagging system | mysql statements] search for multiple tags
Date: 02/13/09
Keywords: no keywords
Hello,
I've hit a snag with my tagging system. I can find items tagged with tag x, but I can't find items tagged with tag x and tag y.
My tagging system is set up like this: entries, tags, entry_tags. The entry_tags joins tags with the specified entry.
In this way, each tag has its own row... so it's tag 1 to entry 1 is separate to tag 2 to entry 1 (as opposed to tag 1 and tag 2 to entry 1).
What I'm trying to do is select an entry with two or more tags attached to it. So, I guess I'm looking for something like:
tag 1 to entry 1
tag 2 to entry 1
tag 1 to entry 2
... and selecting entry 1 when searching for tag 1 and tag 2. Not entry 2.
Unfortunately, I can't seem to find an appropriate string for it. I've tried using FIND_IN_SET() and IN() but they're displaying all entries with any of the tags submitted, and not ... all of them. I've also tried using lots of ANDs but that doesn't work either.
I'm not sure what else to try? I thought this would have been rather straightforward. :P
Thanks for any help. :)
Source: http://community.livejournal.com/php/657532.html
-
Tracking User Downloads (previously posted php_mysql)
Date: 02/11/09
Keywords: php, mysql, sql
I’m using PHP and MySQL to create a dynamic page that delivers files to users based on group settings.
The user is given a variety of files to download, based on their unique settings.
I want to track what files the user selects to download.
For the life of me…I can’t figure out how to do that without creating a button for each file.
(The button triggers an entry into the appropriate table and starts the download.)
Is there a more elegant solution??
(I’d rather do it within a hyperlink)
Appreciate any help!
Source: http://community.livejournal.com/php/657215.html
-
Create thumbnail of any doc
Date: 02/04/09
Keywords: no keywords
Has anyone run across a class to create thumbnails from any document (of course, including images)?
Source: http://community.livejournal.com/php/657129.html
-
Internationalization
Date: 02/04/09
Keywords: no keywords
Following rtimmons's advice, I've been trying out gettext() for a few days. It's pretty awesome. I also figured out the dilemna in my last post:
echo vsprintf(gettext("This is a %sstring%s!"), array('',''));
It works pretty well.
Source: http://community.livejournal.com/php/656740.html