Hi there...
I wrote a PHP script which extracts the title and content from all the
HTML files in a directory and puts the filename, title and content into
a 2 dimensional array.
I know the array is fine because when I print it to the page it dislays
properly.
When I try to input it into the
I have been trying for months now (on and off) to get mail() working in
OS X. I have trid various things, but this is my current setup. If you
have any suggestions or if you could put me in the right direction, then
I would be glad.
- I am using PHP v4.0.6 on Mac OS X 10.1 (pre-compiled with
Javascript is your way to do this, but there are obviously a few ways you
can do that aswell. You don't want to have to submit a form and reload
images/pages etc, so javascript is the only way to go (or dhtml or other
stuff)
One way to do this is either with layers (hide/unhide depending on what
I have a successful website with authenticatin and logons. There are
sections that I allow anyone to get to, but the others have to be
authenticated. This site is not using frames at all. its a page by
page,
with the unit that does the authentication and sessions being included
in
You shouldn't need to unset session variables if you're going to use them
again, just write over them. And to check if a session variable has been
used or not, you can use:
if (session_is_registered($qty)){
calcluation in here
}
If the calculation part is the same in your 'if'
A few things to check:
1. You have a connection to the database (I'm assuming you do).
2. mysql_query() is a php function so you should not put a dollar sign
before it (indicating it is a variable. If you want mysql_query() to return
a variable, do something like this: $result =
Checking a small database for username/password combination would happen so
quick, it would be nearly impossible for two usernames to be entered in.
Your script should work properly, but to make sure no duplicates are
entered, you can change the column definition using the ALTER columnName
You missed the SET parameter in your query... example is below...
$query = INSERT INTO Canidate SET (FirstName, LastName, Indus...
Adam
-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 04, 2002 11:06 AM
To: [EMAIL PROTECTED]
Subject: Re: FIle
You use a link management system.
You can find examples of these all around the web, but I know you can
get some at http://www.hotscripts.com They are also probably more
complex and flexible than what i describe below.
Basically what it does (you could even write it yourself) is this:
1. All
I think this is what you're getting at:
select name=artistID
option value=?= $row[ID] ??= $row[ArtistName] ?/option
/select
or something like that so it would look like (in HTML)
select name=artistID
option value=23Artist's Name First in list/option
option value=44Artist's Name second in
What you *should* do is have a lastUpdated field in your posts table, and
the value inserted into their is the date when you update it.
Then your query would be like
$sql = SELECT posts.topic_id, posts.forum_id, topics.topic_title,
topics.topic_replies
WHERE topics.topic_id =
I presume that the session is not updating because PHP does not
automatically overwrite session variables.
You should use something like this:
$category = $HTTP_GET_VARS[category];
session_register(category);
Session register can be called more than once, and has no effect on
current session
The following code is how you should retrieve the data from mySQL...
if you wanted to update all of the information through one button,
though, I would do it in a slightly different way...
?php
$sql = SELECT whatever FROM whatever...;
$result = mysql_query($sql);
while ($row =
Hi.
I need some guidance for writing an effective query (instead of processing
through PHP).
I lets says I have two tables, tblCDs and tblOrders.
tblCD
cdID| cdTitle | cdArtist
--
1 | Great Hits | Bon Jovi
2 | Forever
If the variable $SCRIPT_NAME does not suit your needs, try the other
environment variables here:
http://www.php.net/manual/en/language.variables.predefined.php
Adam
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi Keith,
I read your post and decided to write a function for you. Basically what
it does is does, is take in a string, and optional newline and value
separators, and outputs an associative array.
It actually works, and has a few comments... so yeah, enjoy.. and thanks
for the challenge : )
PHP cannot recognise javascript variables because javascript is
interpreted via the browser, and not the server (which php is). for php
to use javascript variables, you must post the variable to another page
using either a form or querystring.
Adam
script
I have done an address book in php, although I kept the
username/password in with the rest of their details. If you wanted to
keep it all in two tables, then go ahead. You really should have an ID
field in every table, whether you use it or not, and most of the times,
you'll find you will use
You cannot use javascript variables in php, nor php variables in
javascript, unless you write the variable to the page (for php -
javascript) or post to a new page with querystring or form
(javascript - php).
php - javascript:
script language=JavaScript
var jsVariable = ?= $phpVariable ?;
Maybe I am missing something but it seems you are doing things in a
potentially unreliable way.
Firstly... your sql statement in create.php
$query_update = INSERT INTO pets (uid) SELECT uid FROM users WHERE
uid={$session[uid]};
could simply be
mysql_query(INSERT INTO pets SET uid = .
SELECT * FROM 'Documents'WHERE (CourseRef='4712' AND
Valid_From=#26/03/2002# AND Valid_Until=#26/03/2002#) Order by
Author,Title
should be
SELECT * FROM Documents WHERE (CourseRef='4712' AND
Valid_From=#26/03/2002# AND Valid_Until=#26/03/2002#) Order by
Author,Title
your table name should
Simple do these checks and you'll be sweet as a nut
Adam
?php
$sql = SELECT nickname FROM tblUsers WHERE nickname = '$nickname'';
$result = mysql_query($sql);
$sql = SELECT email FROM tblUsers WHERE email = '$email';
$result2 = mysql_query($sql);
if (mysql_num_rows($result)){
Just some advice... You should use a consistent programming style,
especially with PHP. You can read some guys advice here.
http://www.phpbuilder.com/columns/tim20010101.php3?page=1
Some of the advantages of having a consistent style, is when you are
looking for bugs. If you look over your
Dave,
Javascript is client side.
PHP is server side.
Obviously the limitations imposed by each of the languages is evident.
PHP can't do anything once the output is sent to the browser.
JavaScript can't do anything before it gets sent to the browser.
But, each is important as the other.
Learn
Hello everybody,
There are some techniques which I use that come in REALLY handy when
writing PHP (or even ASP). I will just go through them here briefly. Any
questions? Email me.
1. Keep a php file (lib.php) inside a 'code' folder in a directory for
every site you work on (depending on
This should be it (if I am understanding you correctly).
Adam
$strSQL = SELECT SUM(columnName) as sum FROM tblName;
$result = mysql_query($strSQL);
while ($row = mysql_fetch_array($result)){
$total = $row[sum];
}
Hi all,
Is there a way for me in PHP4 to
Hey there,
I was just looking at your code, and I also look at other's code, and I
think people are making life difficult for themselves. Sure a lot of
people on this list are beginners, but thats more te reason to simplify
code...
One thing you should always do, is write functions... I have
Hello all,
I am creating a finance manager in php and mysql for my own accounting
purposes (and to broaden my skills in php and sql) and I have a couple
of pages where I view statistics on how much I spend, etc, and what
patterns are formed from my spending.
I have made a couple of pages
I think this is something like you would want...
Adam
SELECT users.id, username, MAX(stamp) as stamp, filename
FROM users, files
WHERE users.id = userid
GROUP BY username
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi Bill,
Looks like you're making it hard for yourself, by querying the database for each
record found. Here is some code which should make your life easier. Of course, I have
developed functions which would turn the following code into 10 or so lines, but this
should work for your situation.
Hi Matt,
I think this might be the answer to your problem. It basically checks if
the string is an integer. I generally love the PHP automatic type
conversion, but sometimes it can trick ya :)
if (intval($val) == $val){
// integer stuff
} else {
// string stuff
}
Adam
Hi Bob,
I have written some functions which make select lists much easier. I
have two functions:
- BuildQuickSelect() - you pass a couple of parameters (tablename, etc)
- BuildSelectMenu() - you pass $sql and some more parameters
Unfortunately, they require a few things (such
Hi Hermann,
This has been covered many times on this list, but the basics are this:
PHP retrieves all information and outputs it into a javascript array -
this way all combinations are available to javascript. Then when the
user selects a list from the menu, javascript determines the
What you said (Mike) is mostly correct, although the GetSQLValueString()
function in Scott's code automatically puts the quotes around the values
if the datatype definition of text is passed to the function.
Adam
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit:
You should not rely on the autonumber as a sorting method. You should use it
as a reference. I see you have two easy options (there may be more, but this
seems suitable).
1. Get the SQL to pull a random record (requires mySQL 3.23.x or higher)
SELECT * FROM tblName ORDER BY RAND()
another way to do this is (quicker, using only one query):
$delete_IDs = implode(,,$name_array);
$sql = DELETE FROM $mysql_table WHERE id IN ($delete_IDs);
mysql_query($sql);
or you could delete the first line (implode) and take the square
brackets out of the name of the form field. this will
Sorry if you are a newbie..
but if might help if you delete the records before you select them to display in
html
ie: put the delete query at the top of the page, just after this line:
require (templates/db_connect.php);
adam
Simply open the javascript window with a querystring..
so you have some like this in your javascript code:
window.open(somepage.php?var1=value1var2=value2,theWindow,width=200,
height=300);
and if the variables are inside php... use something like this:
window.open(somepage.php?var1=?= var1
Just a correction you can use arrays with querystrings
page.php?var1[]=firstvar1[]=secondvar1[]=third
$var1
Array
(
[0] = first
[1] = second
[2] = third
)
OR
page.php?var1[]=firstvar2[2]=secondvar2[]=third
$var 1
Array
(
[0] = first
)
$var2
Array
(
[2] = second
First of all, you are not using the variable when you are passing it to
the sql string. Second, you are doing a pointless var check, and
thirdly, your condition statement is flawed.
1. SQL should be (if you have register globals turned on, otherwise you
must use $_GET['_Name1'] ):
$_query =
This sounds very interesting. As far as I know, there are no automatic functions to do
this, although i don't think it would be too hard to write the php function to do
this. If end up finding a solution, please email it to me (and the list), or if you
need a hand in writing it, I'd be happy
Study these two parts in the manual, and you will know how to do everything you've
mentioned (and more).
http://www.php.net/manual/en/ref.strings.php
http://www.php.net/manual/en/ref.array.php
Adam
Just reiterating over what the others have said (plus expanding), and
just a bit cleaner.
SCRIPT language=JavaScript
!--
function deleteRecord(recordName, recordID)
{
if (confirm(Do you really want to delete + recordName+?){
window.location = /delete.php?id=+recordID;
This is friendlier, cleaner and faster way to return the results.
$chk = implode(, , $chk);
$sql = SELECT field1, field2 FROM tblName WHERE ID IN ($chk) ORDER BY ID;
this should bring back all the records within one resultset, which is easier
to manage
Adam
--
PHP Database Mailing List
Firstly, don't cross post unless the question *really* has to do with both (in this
case, it should be just db).
Secondly, your id field should only be used as a reference to a row (not showing order
of record). Auto increments are exactly that, the rdbms will take care of creating the
Yes, I see a few benefits.
1. It makes the code easier to read.
2. It makes the code easier to debug.
Imagine the following:
$sql = SELECT * FROM tblName;
$result = mysql_query($sql);
Now if you want to print the sql and not do the select, you would simply add a line
$sql = SELECT * FROM
Try using parentheses inside your sql:
Select * from table_name where (col1=1 OR col2=1) and col3=0
Select * from table_name where col1=1 OR (col2=1 and col3=0)
They make a big difference, also helps to indentify what you're selecting when you
come back to the sql later.
Adam
You need to uncomment two lines in the httpd.conf file then restart apache
there are many places on the internet where it shows which lines (you could do it
yaself, it has php4 in the lines)
also, make sure apache is turned on, you can do this inside system preferences
apple has some good
Use getdate() with mktime() and this is your solution.
http://www.php.net/manual/en/function.getdate.php
http://www.php.net/manual/en/function.mktime.php
Adam
The first argument passed to eregi_replace is
.$keywords[$i].
You are concatenating the string and a space on the end and front. This was
obviously used as a hack to make sure only full words were highlighted. A
fix for this? A simple hack would be to take out the spaces, so it is simply
Yes, PHP is very cool, and handles memory management for you.
mySQL resultsets and connections are cleaned up once the page has finished executing
(is in manual).
The reason why you would want to use these functions is if you have a script that does
not finish (such as one that handles port
Bartosz was correct in saying that you should use your query to sort,
rather than sorting array. And the array is actually sorted, although
it keeps its index. See the manual reference on arrays to see how they
work. To iterate over sorted arrays, use the foreach() construct.
Anyway, the
When using aggregate functions in sql, it is good to name that expression
using the AS keyword.
Try this:
$result = mysql_query(select password(.$_POST['password'].) AS pword);
while ($p = mysql_fetch_array($result, MYSQL_ASSOC)){
$pswrd=$p['pword'];
}
Also, like David said, you should
I was wondering if anyone has some resources (links or scripts) on 'advanced site
searches'. Something that is similar to the way regular search engines process
requests.
ie. phrase or two word +required -not included
Also, returning details of that search, say for example returning 10
are you using?
---John Holmes...
-Original Message-
From: Adam Royle [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 09, 2002 2:09 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Advanced search scripts
I was wondering if anyone has some resources (links or scripts) on
'advanced site
Create an array and go through the array as needed.
Here is some code from one of my db functions:
$DB_RESULT = mysql_query($sql) or die(Error executing query: .
mysql_error());
// create an empty array to fill with data
$arrData = array();
$rowCount = 0;
Also, if you're not sure how to get the values from $arrThisRow /
$arrNextRow:
echo $arrThisRow['columnName'];
or $arrData[$i]['columnName'] if you want to access it manually without
the other two arrays
adam
On Monday, October 14, 2002, at 06:05 PM, Adam Royle wrote:
Create an array
I was wondering about people's thoughts on file security through php
using database authentication.
Take the following example:
I have a folder (in webroot) called /videos/ which contains a heap of
files like so:
video_1_14-06-2002.mpg
video_2_15-06-2002.mpg
video_3_16-06-2002.mpg
You could do something as simple as this:
a href=displayPic.php?image=/path/to/image.jpgtitle=This is my titleimg
src=/thumb.jpg border=0/a
I think most browsers will convert the spaces in the link (when clicked) to '+' or
'%20', but this may not be true with some less popular browsers (i
No built-in function, but this can be handy (i have it inside a getData() function,
which also lets me output data in a number of ways)
HTH, Adam
$sql = SELECT * FROM .;
$DB_RESULT = mysql_query($sql);
$arrData = array();
$rowCount = 0;
while ($r =
Hi,
Just wondering, which is the better method:
1. Using PHP sessions ($_SESSION['var'] = val;)
2. Using mySQL-based sessions (as described in this thread)
I know if you're using multiple servers, a DB-based session would be handy.
Any comments, anyone?
Adam
Sorry about previous post (some stupid shortcut key made it send)
Your row:
$sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');
should be:
$sql = INSERT INTO count VALUES('$dept', '$deptsub', '0');
You missed the double quotes.
Adam
--- Original Message ---
Hi,
for some reason
I would imagine your game would have two frames (one hidden frame), and the hidden
frame would contain scripts to check and update page.
In the bottom frame i see you might have two choices:
1. have a meta refresh which checks every 5 (or so) secs if a move has been made, and
if detects a
Use:
set_time_limit(0); // let script run forever
Have a look at output control functions, particularly:
ob_start();
ob_flush();
They might help you
Adam
--- Original Message ---
Hi, I'm still new in PHP...,
I have some problem in using sleep() function.
Actually, I want to make a script
There are databases / packages you can buy which already have this
information in them. A simple search for 'purchase postcode database'
on Google gave me a few leads.
Adam
Hi folks,
I'm building a PHP/MySQL database for a customer. It's an advanced
mailing
list for a band. They want to be
Yep. Been using Mac OS X (10.1 - 10.2.3) with mySQL no problems. I
built it from source first time, but now I just use Mac OS X packages
from Mark Liyanage. You can find them here. Also he has a good
pre-compiled PHP4 you can download and use.
http://www.entropy.ch/software/MacOSx/mysql/
Adam
Just use a combination of mysql_errno() and mysql_error():
echo mysql_errno() . : . mysql_error(). \n;
Adam
PS. Documentation always rocks!
Hi guys,
I've been playing with PHP for a while now, and love the mysql
functions,
but there's one thing I'd like to know...
I want to check if a
Hi Mignon,
This should work, never closing the window without submitting
(foolproof). Just add some error checking, and you'll be sweet as a
nut! All I did was add the echo statement underneath the data insert.
Adam
?
include ('dbconn.php');
if(isset($submit))
{
$query = INSERT INTO
This should work. You were on the right track, although you might want to
use better var names so you don't get confused. You can see I have changed
them to what I would normally use.
Adam
?php
$sql = select * from users;
$result = mysql_query($sql, $connection) or die(Couldn't execute
Try this. PHP arrays are cool! Of course there are tidier ways to
implement this, but this is just an example.
Adam
-- Code --
$getscname = mysql_query(SELECT * FROM subcat WHERE subcatid =
'$subcatid') or die (Couldn't get the info.br.mysql_error());
while($sub_cat =
Hi Mihai,
Didn't try your code, but noticed your comment on colours. RBG values go from 0 - 255,
not 1 - 256, so this may be your problem.
Adam
SELECT B.Title FROM phpCalendar_Details AS B, phpCalendar_Daily AS A
WHERE A.CalendarDetailsID = B.CalendarDetailsID AND CURDATE( ) BETWEEN
A.StartDate AND A.StopDate
Also, you don't need to use the backticks around field names unless they contain
spaces or other reserved words and
This may not be true in your case, but I remember another user on this list claiming a
similar thing, and his problem was actually code-related. He had his db update code
*AFTER* the results were displayed (ie. doing edit and save on same page).
Check your programming logic. Just a note to
Hi Don,
Use this process:
?php
// create an empty array to fill with data
$data = array();
$row = 0;
while ($r = mysql_fetch_assoc($result)){
foreach ($r as $key = $value){
$data[$row][$key] = $value;
}
$row++;
}
?
The array structure would be something like this:
SELECT b.name FROM apliexperts a LEFT JOIN experts b ON a.expid = b.id
WHERE softid = 2
I have a table that includes the ids of software
aplications and experts (apliexperts). My page is
loaded with the variable of the software id (softid),
which it uses to match the experts for that software.
I have seen an example using JavaScript where javascript commands are flushed every so
often (from PHP) which indicates a status bar process. It was used to monitor
mailouts. The javascript commands were simply telling an image to increase it's width.
Of course you have to have a system where
It's probably better to use arrays.
$tips[0] = value;
$tips[1] = value;
$tips[2] = value;
Although, if you REALLY want dynamic variable names.
$i = 1;
$varname = 'tips_'.$i;
$$varname = value;
this will make a variable like below:
$tips_1 = value;
But like I said before, it's better to use
I assume the field 'date' in your database is a date field, and in your code
you are trying to do a date + 1, but you are not specifying *what* you are
adding to the date (ie. 1 day, 1 week, 1 month), therefore the whole
variable is being replaced (with a 1). Try looking at the various date
This is neither a PHP nor database question. This is client side.
Anyway, a simple fact is that tables won't render until the whole table
has been loaded into memory (ie. it won't show until it reaches the
/table tag). If you have your whole site inside one big table, then
this is what is
Hi Aaron,
I found this on a little useful when I started learning regex. Good
luck 2 ya!
adam
http://www.devshed.com/Server_Side/Administration/RegExp/
Hi All,
Sorry for OT post but need some info.
Does anyone know a good tutorial that explains regular expressions in
DUMMY terms?
I have a
80 matches
Mail list logo