php-general Digest 30 May 2005 09:01:34 -0000 Issue 3483
Topics (messages 215967 through 215978):
Re: novice: how to run .sql script from php?
215967 by: M. Sokolewicz
215968 by: Rory Browne
215971 by: Marek Kilimajer
Free penetration test: my 2¢
215969 by: Andy Pieters
Dummy question about gettion "select option" choosen
215970 by: Mário Gamito
215978 by: Jochem Maas
Re: Replacing 2 strings
215972 by: Brian V Bonini
Can't Get PHP to work
215973 by: Subscriber
Re: Questionary Development
215974 by: Rory Browne
Re: php based "open source" document workflow
215975 by: Rob Scovell
Re: Regex question: replacing incidences of character when not enclosed within
HTML tags? (somewhat solved)
215976 by: Murray . PlanetThoughtful
Re: Warning: filemtime() (errno=75 - Value too large for defined data type)
215977 by: Christopher Curtis
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
tony yau wrote:
I realised that there is a fundamental problem with using mysql_query( ...)
to run a .sql script to setup a database, and that was the database needs to
be there in the first place for php to connect to! also there was a lot of
comment lines in the script that was causing problem. ... so I gave up
trying to parse the file.
instead I did this
1) create the database with phpmyadmin etc
2) remove (by hand) all comment lines from the .sql file
and then include the file
ob_start();
include 'installation.sql';
$contents = ob_get_contents();
ob_end_clean();
this is *very* overTheTop; why not just do:
$contents = file_get_contents('installation.sql');
???
execQuery($contents);
not very good but does the job.
thanks for all the help
tony yau
"Rory Browne" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I'm assuming that the .sql file consists of a list of MySQL queries,
that when performed sequentially will set up your system.
That being the case, the perfered way ot install the thing is to do a
'mysql [host/username/password parameters] < file.sql'.
I believe you can also run file.sql scripts using phpMyAdmin.
If you were to define a mysql_run_script() function, it would look a
bit like the following:
<?pseudo_code
function mysql_run_script($file){
$sql = file_get_contents($file);
$queries = split_sql_into_individual_sql_queries($sql);
foreach($queries as $query){
mysql_query($query);
}
}
?>
Come to think of it, you could turn the above pseudo code into valid
php code, by defining the split_sql_into_individual_sql_queries()
function. This would involve splitting by ';', taking into account the
possibility that ';' may occur in the middle of a string.
Check out the code for phpmyadmin, or phpbb(db backup/recover
feature), for a better idea.
On 5/27/05, tony yau <[EMAIL PROTECTED]> wrote:
Hi All,
I got this .sql script that setup the whole db schema, I can run
mysql.exe to run on my pc but when it goes to a hosting company's server I
don't have that command!
So I tried to include("setup.sql") into a string and send that as one
long sql query. BUT I need to get rid of all the comment lines first in
the
script!!
can someone give me a better idea of doing this.
(there must be an equivalent php function like
mysql_run_script("setup.sql"))
thanks
--
Tony Yau
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 5/29/05, tony yau <[EMAIL PROTECTED]> wrote:
>
> I realised that there is a fundamental problem with using mysql_query( ...)
> to run a .sql script to setup a database, and that was the database needs to
> be there in the first place for php to connect to! also there was a lot of
> comment lines in the script that was causing problem. ... so I gave up
> trying to parse the file.
Umm, I suggest you read an awful lot more on mysql. I could be wrong
on this, but I can't at face value see anything wrong with
mysql_query("create database database_name"); mysql_query("use
database_name"). Your problem seems to be your lack of knowledge
regarding mysql, and using mysql from PHP.
>
> instead I did this
> 1) create the database with phpmyadmin etc
> 2) remove (by hand) all comment lines from the .sql file
> and then include the file
>
> ob_start();
> include 'installation.sql';
> $contents = ob_get_contents();
> ob_end_clean();
> execQuery($contents);
> ob_start();
> include 'installation.sql';
> $contents = ob_get_contents();
> ob_end_clean();
is spagetti code. use $contents = file_get_contents("installation.sql") instead.
is a bad way of writing that: $contents =
file_get_contents("installation.sql"). Where did you get the
execQuery() from? If you have an execQuery() function that allows you
to do multiple queries seperated by semicolons, then you're sorted. 1
>
> not very good but does the job.
> thanks for all the help
>
> tony yau
>
> "Rory Browne" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> I'm assuming that the .sql file consists of a list of MySQL queries,
> that when performed sequentially will set up your system.
>
> That being the case, the perfered way ot install the thing is to do a
> 'mysql [host/username/password parameters] < file.sql'.
>
> I believe you can also run file.sql scripts using phpMyAdmin.
>
> If you were to define a mysql_run_script() function, it would look a
> bit like the following:
>
> <?pseudo_code
>
> function mysql_run_script($file){
>
> $sql = file_get_contents($file);
>
> $queries = split_sql_into_individual_sql_queries($sql);
>
> foreach($queries as $query){
> mysql_query($query);
> }
>
> }
>
> ?>
>
> Come to think of it, you could turn the above pseudo code into valid
> php code, by defining the split_sql_into_individual_sql_queries()
> function. This would involve splitting by ';', taking into account the
> possibility that ';' may occur in the middle of a string.
>
> Check out the code for phpmyadmin, or phpbb(db backup/recover
> feature), for a better idea.
>
> On 5/27/05, tony yau <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I got this .sql script that setup the whole db schema, I can run
> > mysql.exe to run on my pc but when it goes to a hosting company's server I
> > don't have that command!
> >
> > So I tried to include("setup.sql") into a string and send that as one
> > long sql query. BUT I need to get rid of all the comment lines first in
> the
> > script!!
> >
> > can someone give me a better idea of doing this.
> > (there must be an equivalent php function like
> > mysql_run_script("setup.sql"))
> >
> >
> > thanks
> > --
> > Tony Yau
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
tony yau wrote:
I realised that there is a fundamental problem with using mysql_query( ...)
to run a .sql script to setup a database, and that was the database needs to
be there in the first place for php to connect to! also there was a lot of
comment lines in the script that was causing problem. ... so I gave up
trying to parse the file.
instead I did this
1) create the database with phpmyadmin etc
so you have phpmyadmin installed. good. now while you have the database
selected,
2) click the SQL (it's in the toolbar in the right frame)
3) click "Browse..." button, find the .sql file, click OK
4) click the bottom "Go" button, wait and relax
--- End Message ---
--- Begin Message ---
Hi all
I would like to thank everybody for helping me.
Quite honestly, I didn't even remark the referal id. I guess that's because
if your looking at links all day long, you kinda block certain things. Like
seeing only the hostname part of urls.
Secondly, as far as I am concerned, no harm's done since I specifically asked
for free (as in price), I wasn't planning signing up for any paid service at
all. So like someone said 35% of nothing is still nothing right? Except,
some sites give a (small) buck on referals regardless of signing up.
Thirdly, despite what I said previously, which was said after a very long day,
and where I was very tired and confusing heads for tails, I do find that
anyone who gives a link, and adds a referal id to it, “should” add a
disclaimer to the message stating their affiliation.
Being shy for money myself, I can understand that someone will take any and
all oportunity to make an extra buck, but doing it this way is not very
honest.
Show your professionalism, add that disclaimer, people will respect you more
for it.
Thank you all for your help and thank you PHP!
Keep up the good work
With kind regards
Andy Pieters
Straight-A-Software
--
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
under the GPL2 and that are meant for use with a
php cli binary:
http://www.vlaamse-kern.com/sas/
--
--
--- End Message ---
--- Begin Message ---
Hi,
Thank you all who have helped me in the checkbox's question.
This is an area to which i'm very fresh in PHP.
I now have this code in a form:
---------------------------
<select name="interesse[]">
<option>1</option>
<option>2</option>
<option>3</option>
(etc...)
</select>
--------------------------
My question is, how can i, in the action code, retrieve the option
choosen by the user ?
My most apologies for yet another dummy question, but i google and
google, and i always end up seeing examples fulls of complexity, when i
want is such a simple thing.
Thanking you in advance.
Warm Regards,
Mário Gamito
--- End Message ---
--- Begin Message ---
Mário Gamito wrote:
Hi,
Thank you all who have helped me in the checkbox's question.
This is an area to which i'm very fresh in PHP.
I now have this code in a form:
---------------------------
<select name="interesse[]">
<option>1</option>
<option>2</option>
<option>3</option>
(etc...)
</select>
if the form containing this element is posted then the following will
so you what exactly is posted:
var_dump( $_POST['interesse'] );
which should show you an array of one or more items, which either
come from many form elements named 'interesse[]' OR from a single
element named 'interesse[]' where that element is multiselect
(in which case the definition should be something like:
<select name="interesse[]" multiple>
or
<select name="interesse[]" multiple="multiple">
btw: its not that hard to create a test form with elements
you intend to use and then submit it to a test script that
just outputs what has been posted... so you can see for yourself
what is returned and which vars you need to access in order
to retrieve whatever value you want/need... to see everything
that was posted simply do the following in you [test] submission
handler script:
echo '<pre>' // this just makes it easier to read the var_dump() output.
var_dump( $_POST );
--------------------------
My question is, how can i, in the action code, retrieve the option
choosen by the user ?
My most apologies for yet another dummy question, but i google and
google, and i always end up seeing examples fulls of complexity, when i
want is such a simple thing.
Thanking you in advance.
Warm Regards,
Mário Gamito
--- End Message ---
--- Begin Message ---
On Sun, 2005-05-29 at 12:22, W Luke wrote:
> Hi,
>
> I have some text in a file which, when it's dumped to a var, needs to
> be replaced. In its raw form, it looks like this: <^JIM_JONES> and I
> need to remove the <^_ and > characters and have it read "Jim-Jones"
>
> It's nestled in amongst a load of other text - I'm fopen'ing a file
> and reading it line by line - the text-to-replace is just in a var
> named $text1
>
> Any ideas would be great
>
> Will
Someone much more clever that I can probably come up with something much
cleaner and efficient but.... This works...
<?php
function replace($string)
{
$chars = array("<", "^", ">");
$string = str_replace($chars, "", $string);
$string = str_replace("_", "-", $string);
$pieces = preg_split('/-/', $string);
foreach($pieces as $char) {
$first_letter[] = $char{0};
$remainder[] = strtolower(substr($char, 1));
}
$result = array_merge($first_letter, $remainder);
list($frstltr,$lstltr,$frstwrd,$lstwrd) = $result;
$string = $frstltr . $frstwrd . "-" . $lstltr . $lstwrd;
return $string;
}
$text1 = '<^JIM_JONES>';
echo replace($text1);
?>
--
s/:-[(/]/:-)/g
Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org
--- End Message ---
--- Begin Message ---
Hi,
I sure hope someone here can help me. I spent the entire day yesterday
and most of the evening setting up a webserver on my Windows 2000 Pro
system.
I've got PHP 5.04, MySQL 4.1.12, ActivePerl 5.8.6, Java Runtime
Environment, Tomcat 5.5.9, ZendOptimizer 2.5.10, MyODBC 3.5.11 and
phpMyAdmin 2.6.2 all installed.
From what I can tell, all is working well except PHP and phpMyAdmin.
I added PHP to my path like this:
C:\Perl\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\php;C:\Apache2\bin;C:\mysql\bin;C:\php\dlls;C:\Program
Files\Common Files\Ulead Systems\MPEG;"C:\Program Files\Zone
Labs\ZoneAlarm\MailFrontier"
I've got a copy of php.ini in both my c:/php directory and in
c://winnt. I've listed my user directory as c:/apache/apache2/htdocs
and I've placed phpmyadmin in htdocs.
But when I try to view a php page I get an error or page cannot be
displayed. On a couple of occassions I viewed the raw php data in my
browser.
Also, when I try to add a php extension using "LoadModule" in my
httd.conf file I get an error loading Apache telling me that "the file
cannot be found" (but I've verified it exists - like php5apache.dll and
php5ts.dll).
Can someone please help me figure out where I'm screwing up at?
Thanks in advance!
Edited to say I'm getting Closer!!!
Now when I go to
[url=http://localhost/phpmyadmin]http://localhost/phpmyadmin[/url] I get
the following info:
cannot load mysqli extension;
please check PHP configuration
[u]Documentation[/u]
And the documentation says:
[b][1.20] I receive the error "cannot load MySQL extension, please check
PHP Configuration". [/b]To connect to a MySQL server, PHP needs a set of
MySQL functions called "MySQL extension". This extension may be part of
the PHP distribution (compiled-in), otherwise it needs to be loaded
dynamically. Its name is probably mysql.so or php_mysql.dll. phpMyAdmin
tried to load the extension but failed.
Usually, the problem is solved by installing a software package called
"PHP-MySQL" or something similar.
I have tried using both mysql and mysqli in config.inc.php (phpmyadmin
config file) and either way I get the same error message. And in
php.ini I have enabled the following extensions:
extension=php_mysql.dll
extension=php_mysqli.dll
--- End Message ---
--- Begin Message ---
If you insist on doing this serverside, then personally I'd probably
use hidden form fields. If you're open to doing it client side, then
I'd probably out the information into five <div> sections, only one of
which would be visible at any one time. using dhtml. What you want is
the CSS visibility attribute. Only one <div> would be visible at any
one time.
On 5/28/05, ...helmut <[EMAIL PROTECTED]> wrote:
> I have a form that contains 100 questions. To make it easier on the user, I
> will divide it into 5 sections (20 questions per section), then all the
> information will be written to a db. What is the best way to carry along
> through the pages the information that has already been submitted? Cookies?
> Writing to a DB after each section? Session Variables?
>
> I read that writing to a database as i go along could be too much of a
> hazzle for the db, specially if I have multiple people filling out the form
> at the same time.
>
> TIA
>
> --
> ....helmut
> helmutgranda.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Well ... it's not PHP but Mason, and it's called "Bricolage". (It's an
Open Source content management system). And it's not straightforward ...
but it can cover the sort of thing you are talking about with some
tweaks. You will need to set it up so that you can use it to pass Word
(or whatever) docs between work desks.
http://www.bricolage.cc/
Rob
bruce wrote:
hi...
i'm dealing with a project where i'm going to have users deal/modify a
number of docs.. i'd like some sort of doc workflow process where i can
allow a given user/type of user access to the doc, and move the doc along
the process.
ie,
eng -> develops the doc
test-> tests the doc
qa -> reviews the doc
doc signed off/complete...
this kind of process would have the eng/test/qa person touching the doc, and
only after all have signed off on the doc, would it be complete.. i'm going
to be dealing with potentially ~2000 docs, so i''d like to have a system in
place that allows us to more or less track what's going on.
does anybody have any thoughts on an open source solution for this kind of
situation.
thanks
bruce
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
> So, thinking about it a little more, I decided what I was looking for was
> a
> regular expression that would allow me to replace any incidences of
> hyphens
> when not contained within tags (i.e., when not contained between "<" and
> ">").
>
> And this is where things have ground to a halt.
Hi All,
After toying with this for several hours I decided to give up on trying to
work out a way to achieve this via a single regular expression replacement.
My simpler 'solution' now is to pull out all text not contained within tags
using preg_match_all(), and run a str_replace() across these values to
replace any incidences of hyphens, and then another str_replace() to replace
the content with the substring where hyphens were found.
So, something like:
<?
preg_match_all("/(^|>)(.+?)(<|$)/m", $text,$hypharr);
for ($i=0; $i < count($hypharr[0]); $i++){
$rephyph = str_replace("-","-<span style='font-size: 0px;'>
</span>", $hypharr[0][$i]);
if ($rephyph <> $hypharr[0][$i]){
$text= str_replace($hypharr[0][$i],$rephyph,$text);
}
}
?>
This seems to achieve what I'm looking for, ie replacing hyphens when not
contained in HTML tags.
Regards,
Murray
--- End Message ---
--- Begin Message ---
On 5/29/05, Andrew Brampton <[EMAIL PROTECTED]> wrote:
> Warning: filemtime(): Stat failed for master.log (errno=75 - Value too large
> for defined data type) in test.php on line 5
>
> when I do the following line of code:
> filemtime ('master.log');
> My code was working fine until the file reached 2GB.
> P.S I'm running PHP 4.3.10-13 on a Debian distro.
I'm afraid you have two options: either shell out to the 'stat'
command line tool, or recompile the PHP package. You can 'apt-get
source php' and manually edit debian/rules to add the
"-D_LARGE_FILE_OFFSET=64" looking argument to configure, then just
'dpkg-buildpackage -uc -us' it (or debian/rules binary).
There is a bug report against PHP pertaining to this, but it breaks
something in one of the other modules that I can't recall off the top
of my head. I'm thinking it's related to Apache PAM, but that may be
something different ...
regards,
Chris
--- End Message ---