solution-digest
| From: | Trapeer | Date: | Thu, 02 Nov 2000 00:48:26 +0000 |
| Subject: | solution-digest | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-4112@lists.php.net to get a copy of this message | ||
>Date: Wed, 1 Nov 2000 17:52:25 +0530 (IST)
>From: Rajil Saraswat <rajil@iitk.ac.in>
>Subject: embedded sql in a database:novice
>
>hi everyone,
> i am trying to shift a flatfile website into a database. My problem is
>that the flat file contains links(href tags) to other files. I want that
>the href tags should be sql queries to the other pages. how do i change
>the href tags to sql queries. if i do it manually than it will take a lot
>of time as the no of files is very large. can there be a logical solution
>for handling this type of problem. i tried to look up some whitepaper,
>tutorial on this kind of problem. but all sites give mundane information
>on interfacing php and mysql.
>is there any site which gives information on building actual websites
>using php and database?
>
>regards.
>
>Rajil Saraswat
Make a php code which can output any page based on the id of the content
sotred in your db (so, for e.g., create a page that displays your mainframe
(header, menus, etc.) and where it is applicable, it displays the relevant
content. You can do this by setting up rows with an id and a blob which
holds the text itself (to be the most easy, put straight html code in the
fields). Now, if this page works, then simply create a script that reads in
all the files, and stores them in the db. It should work like this:
- get directory info in an indexed array ($fname[0], $fname[1], etc.),
- create a loop that runs as many times as many files you currently have to
process
- in the loop: read in all files,
- split the page into mainframe and contect parts (should be easy if the
design is clear),
- process the content part, look for <a> tags, and change the referring link
so it will not point at the html itself but the renderer php page (which you
did in the beginning) queried with the id of the corresponding file, so for
e.g. <a href="messiah_01.html" (..)> changes to <a
href="render.php?id=9824"
(..)> - this works fine providing that messiah_01.html 's content is placed
in a row having an id of 9824.So, to go into depth of this, get the href
string, look it up in the filelist ($fname[]), and if match found, then
rename it according to the index of the matching filename.
- that's all. :)
later you can add any content just by entering the content type, and if you
are smart, you can even change the design at any time.
- o -
>Date: Wed, 01 Nov 2000 18:21:23 -0800
>From: Claus Nybo <claus@nnwebdesign.com>
>Subject: Preserving format of text fields
>
>
>Hi,
>
>I am working on a website using php3 and mySQL. On one page in the site
>administration is inputting new articles, via a form, with fields such as
>$title, $date, $article, etc. These are then passed to mySQL, to be viewed
>on another page by users.
>
>This all works fine, except for the text of the article itself. When the
>text is typed in to the textfield on the form, it exist of several
>paragraphs, with blank lines in between, but when it is viewed from the
>database on another page all the paragraph breaks and blank lines are gone,
>and all the text is displayed in just one long continued block.
>
>What do I do to preserve the format in which the text is typed? With the
>different paragraf breaks and blank lines?
>
>Thanks for the help!
>
>Claus
Well... Have you ever heard of html? :) In html, a line break in the source
html does not mean anything, you have to use <br> instead. There is a
built-in function ln2br() for exactly this purpose. Use it to convert line
breaks to <br> tags before storing the articles in your database.
- o -
>From: "Trond Erling Hundal" <webmaster@port-industry.com>
>Date: Wed, 1 Nov 2000 18:43:25 +0100
>Message-ID: <MIBBLBJEKKHMEDHENEKCOEIICBAA.webmaster@port-industry.com>
>Subject: Is it possible to comapare values in two arrays??
>
>I have two (turn) tables (and a microphone)...
>Just kidding... eh....
>I have two tables containing information about email adresses, and
userinfo.
>The first table is calles email and the other userinfo
>in the email table i sort all the adresses by type... (about 8 different
>types)
>And the user has the oppotunity to choose which types he needs to send an
>email to (this will be stored in the userinfo table)
>The point is that when the user clicks himself into the page where he can
>control who will be the receipients of his e-mail, all the types should be
>listed, and the ones stored in the userinfo table should be checked...
>
>This isn`t a critical function on this page, and I can do without it. But,
>this is the second time I run into this kind of problem, and I HAVE to find
>out how I can solve it!!!
>
>Could it be that I have a bad normalization of the db or something?? I
don`t
>know....
>
>Please help me!
What the problem in fact is ? It may help if you describe how you tryed to
solve the problem...
- o -
>From: "Bart A. Verbeek" <bodemschat@home.nl>
>Date: Wed, 1 Nov 2000 20:12:00 +0100
>Subject: showsource
>
>Hello,
>
>Is there a function (or something) in PHP to show the source off a script?
>I mean like: file.php3?showsource
>
>And then it pops up with the source of the script?
>
>thanks
>Bart
You must be kidding... Why would there be such switch (query parameter, to
be exact), there would be no use but to make hackers look in your script and
look for your password and/or database structure so even if mysql database
is open to localhost only, and even if they do not get an account for your
machine (which I highly doubt, if they really want :) then they could use
forms on your field which you forgot to filter out bad things from, just to
run for e.g. a drop table query.. ? Or, even if drop is not granted to the
user in question (which access to the database) then they could run az
update and make your table empty? It has no use at all, I think:) Or, even
if you filter out those bad tags and they can do nothing - they could move
to the next site and try all of the above... Now do you think this would be
useful? If you think, and you came here to find out how this could be done,
then I suggest that you better get lost from this maillist...
- o -
>Date: Wed, 01 Nov 2000 06:09:47 -0700
>From: Tom Mahoney <tom.mahoney@riaco.com>
>Subject: postgresql+php+double choco latte
>
>I would like to know if anyone can give me any help or point me in the
>direction of it over a problem I'm having with postgresql php and double
>choco latte. I'm not sure where to start for help so I'm starting here.
>I'm using php 4.0.0 ( and have had the problem with php 4.0.3pl1 as well
>) from source, postgresql 7.0.2 from rpm and dcl-20000905.tar.gz
>I've setup postgresql php and dcl according to instructions from both
>dcl and php README or INSTALL files ( yes I've poked around in the rest
>of the documentation with no luck )
>I succesfully setup postgresql and php for dcl. I'm then supposed to
>login to dcl through netscape with user and password sa to continue
>configuration of dcl. It's at this point that I run into a problem.
>PHP gives me the error below:
>___________________________________________________________
>Fatal error: Call to undefined function: pg_connect() in pgsql.php3 on
>line 60
>Now I looked on the php website and came across the information at this
>url:
>http://php.net/manual/html/function.pg-connect.html
>Which states that the syntax for pg_connect has been deprecated.
>So what I'm thinking is that the syntax above in both conditions ( there
>are two seperate database connect calls which are tried as near as I can
>tell ) is no longer supported yet the url I gave above doesn't make it
>very clear what the syntax has been replaced with. But still the error
>mentioned earlier states that the call is undefined meaning that it's
>not even aware of a pg_connect funtion call.
>I would appriciate what ever help anyone can provide be it pointing me
>to the documentation which talks about how to define function call's
>within php or pointing me to some other source of help.
>Thanks in advance and if I've broken any netiquette rules by including
>the above tidbit of source I'm sorry.
RTFM-type question:) Anyway, read the first few chapters of the manual and
you will get know of controlling structures, functions, reserved words, and
many other fancy stuff... Just like in any other programming language doc
I've seen up to now :)
The other (first) part of your letter makes me think pgsql support is not in
your PHP. You check for it witha simple script:
<? phpinfo(); ?>
If it is not listed, you can still try to load it with dl() (look at
http://php.net/manual/function.dl.php)... But it
has a small chance this
will work if the above did not...
Trap
p.s.: does the .ezm format bother anyone else than me?... It does a much do
bother me especially with mutlipart-coloured-smelling things from the
"great" outlook... I suggest everyone sends mails as plain text or maybe
their letter simply won'tbe read :)