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 li
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
tag). If you have your whole site inside one big table, then
this is what is causing you
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
functio
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 t
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 yo
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.
Bu
Hi Don,
Use this process:
$value){
$data[$row][$key] = $value;
}
$row++;
}
?>
The array structure would be something like this:
$data[0]['Name'] = 'Name 1';
$data[0]['Address'] = 'Address1';
$data[0]['City'] = 'City1';
$data[1]['Name'] = 'Name 2';
$data[1]['Address'] = 'Address2';
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 peopl
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 characte
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
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.".mysql_error());
while($sub_cat = mysql_fetch_ar
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
mail To all my list
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www
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 `com
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
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
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 ab
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 t
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 move,
SELECT tblA.col1 as 'tblA.col1', tblB.col2 as 'tblB.col2', tblB.col3 as
'tblB.col3'
FROM tblA, tblB
Is there a way in SQL to have the column names prefixed by the table
name in a result set after a join?
Table A has column col1 and table B has columns col2 and col3
After the join I want the re
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
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
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 = mysql_fetch_array($DB_RESULT,MYSQL_ASSO
You could do something as simple as this:
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 don't know).
Then displayPic.php might be something like this (if you have latest PHP version):
displ
Hello,
I created a (very) simple class for a polling system. I only developed
it to a certain stage (took me a few hours).
This was how you used it:
$poll = new easyPoll("poll_name");
$poll->PrintVotingPanel();
?>
and if you wanted to show all the results of all polls
$poll = new easy
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
video_4_17-
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
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;
base 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 w
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
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
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 bette
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 ac
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
$
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
You have error reporting set to a value other than 0.
Use this function at the top of your script (or change the values in
php.ini).
error_reporting(0);
For more reference:
http://www.php.net/manual/en/features.error-handling.php
http://www.php.net/manual/en/function.error-reporting.php
--
P
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 info
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
I think the other replies to this are missing the point.
You want to search a text field for the word Wash, and want to put the space in so you
can search with the space, eliminating words which begin with wash. But then, if you
think about it, that means you'd have to search for commas, and fu
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 t
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
increme
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 (
Just reiterating over what the others have said (plus expanding), and
just a bit cleaner.
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
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 to
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 =
Just a correction you can use arrays with querystrings
page.php?var1[]=first&var1[]=second&var1[]=third
$var1
Array
(
[0] => first
[1] => second
[2] => third
)
OR
page.php?var1[]=first&var2[2]=second&var2[]=third
$var 1
Array
(
[0] => first
)
$var2
Array
(
[2] =
Simply open the javascript window with a querystring..
so you have some like this in your javascript code:
window.open("somepage.php?var1=value1&var2=value2","theWindow","width=200,
height=300");
and if the variables are inside php... use something like this:
window.open("somepage.php?var1=&var2
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
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 wi
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() LIM
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: htt
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 contents
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 as
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
> H
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.
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
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 with
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
Hi Dave,
Load the data from the text file into a variable (eg, $fileContents)
Then split the file into an array and run every sql statement.
The following code should work...
Adam
$arrSQL = explode(";",$fileContents);
for ($i=0;$i
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 t
Not sure if you received this previously. Try this query below.
Adam.
$query = mysql_query("SELECT * from 150bk where Signature like '%1' and
150bk.ID ='$rec_id' limit 1");
Should be something like so...
"SELECT text FROM events WHERE date < now() SORT BY date DESC LIMIT 1"
That should work.
Adam
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 secur
Don't complicate your code if you don't need it. IF you need to find out the
length of the string, use PHP's built-in functions. They're faster and they
are easier to write, debug and for others to understand. If I missed your
point completely, forgive me.
And here's the code for you do figure ou
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
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 cod
Simple do these checks and you'll be sweet as a nut
Adam
// you might have this at the top of your form to show the error messages
\n";
for($i=0;$i\n";
}
echo "\n";
}
?>
> Hi all
>
>
>
> I am trying to create a registration area that uses a nickname and email
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 shoul
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 = " . $
In your UPDATE query, should you have a WHERE clause?
eg. UPDATE my_items SET name = '$update' WHERE ID = $ID
OR
do this
$update = $name;
instead of
$update = "$name";
Try running the query on the command line (on *nix) or through phpmyAdmin or something
to see if the query is actually wo
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:
var jsVariable = "= $phpVariable ?>";
javascript -> php:
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
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
>
>
> c=document.forms[0].category.options[
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 : )
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
I have not tested this but it should work...
Adam
this goes in the form area on login.php
-Original Message-
From: its me [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:27 PM
To: [EMAIL PROTECTED]
Subject: login
there is a page that when user go to need to be lo
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
To make sure that other names are not interfered with, I would refine
what you're doing.
ie. "Theater Nuts" would become "ater Nuts, The"
obviously this is not acceptable...
so you would do something like this...
//does it begin with 'The '?
$name_start = substr($band_name, 0, 3)
if ($name_st
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...
Cancel This Domain?
as long as all these are from the same table... the
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 sess
Hey there...
Sometimes it is easier to store the date as a unix timestamp (seconds
since midnight 1/1/1970) cause it allows you to format the date any way
you want, and php has cool date and time functions which rely on a
timestamp.
A time stamp example is like this:
Formatted date: " .
dat
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 = posts.topi
I think this is what you're getting at:
">
or something like that so it would look like (in HTML)
Artist's Name First in list
Artist's Name second in list
Artist's Name third in list
if you select the first item in the list, the next page will produce:
$artistID = "23"
so yah... that
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
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 U
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"
comma
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 = mysql_query("UPDA
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' statement,
> 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
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 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 c
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
92 matches
Mail list logo