Hey,
Whilst you can't perform statements like this, there are alternatives. If
you only have one field in your table, you can use:
"INSERT INTO com VALUES ('pentium'), ('amd')"; // Continue the comma
separated values list
Or, if you need to specify which fields the data is to go in:
"INSERT I
Sorry,
I didn't mean it quite like that. After the user presses submit
$string = htmlentities($string);
// now, do whatever with the string
J
- Original Message -
From: Niklas Lampén
To: James Holloway ; Php-General
Sent: Wednesday, September 12, 2001 9:52 AM
Su
Hey Nate,
_
<[EMAIL PROTECTED]> wrote in message
001001c136af$7c649db0$[EMAIL PROTECTED]">news:001001c136af$7c649db0$[EMAIL PROTECTED]...
Can someone tell me what i'm doing wrong here?
mysql_fetch_array($result2))
{
echo "Print some text here!";
}
?>
Hi Marcos,
use substr();
http://www.php.net/manual/en/function.substr.php
$string = substr($string, 0, 10);
James
"Marcos Lloret" <[EMAIL PROTECTED]> wrote in message
019701c131f1$f57bdfa0$371c94c1@mlloret">news:019701c131f1$f57bdfa0$371c94c1@mlloret...
hi to all,
i have a long string (a
Jaxon,
do you have a line of white space after your closing tag?
Anyway, this looks fishy to me:
if (!isset($page_id))
{
$sql="select page_id from table where fieldname = $value";
$link_id = mysql_connect($host, $usr, $pass) or die (mysql_error());
mysql_select_d
Hi Niklas,
You can use || or OR.
Secondly, huge list of values you say? Can this list be exploded by a
common denominator, like a space or comma? If so, consider this:
$list = // Huge list of words (array), separated by a comma.
$words = explode(",", $list);
$query = "SELECT * FROM table WHER
Hi there,
I haven't tested any of this, and there are probably some things that need
adding, but it'll give you an idea at least.
Form element:
// What files do we want?
$types_we_want = array("image/gif", "image/jpeg", "image/pjpeg"); // allows
jpegs and gifs
// What is the max size we want
Hi Taz,
What happens if they type "NeO", or "NEO", or "nEo", or "neO" (etc)? ;)
Also, if you're using this in a large application (or intend to in the
future), are you going to type out all of the names as you have done with
the neo example?
Bjorn's method is much better, and you're better off ge
Hi there Tijmen,
Firstly, change the input name from this:
voorraad
to this:
voorraad[]
then do something like:
";
for ($i = 0; $i < sizeof($voorraad); $i++) {
if (!empty($voorraad[$i])) {
echo $voorraad[$i];
}
}
?>
James
"Tijmen Hennink" <[EMAIL PROTECTED]> wrote in messag
Hi,
phpMyAdmin allows you to import comma separated files into your mysql tables
(dunno about .csv but certainly .txt files)..
http://phpwizard.net/projects/phpMyAdmin/
Also read up on this:
http://www.mysql.com/doc/L/O/LOAD_DATA.html
as you may eventually need to set up something to enable a
> > Is there a routine out there to strip all characters from a phone
> > number except the numbers? I was going to write my own but
> > figured there must already be one out there I can use. Thanks.
>
> While the solution given will work, consider the following perfectly valid
> phone numbers:
>
If you want to separate insert statements, you can do it like this:
$big_insert_query = "INSERT INTO table (id, col1, col2) VALUES ('',
'$col1_stuff[$i]', '$col2_stuff[$i]'), ('', '$col1_stuff[$i]',
'$col2_stuff[$i]'), ('', '$col1_stuff[$i]', '$col2_stuff[$i]'), ('',
'$col1_stuff[$i]', '$col2_stu
Hi Peter,
You could try this:
italic Blah bold";
$new_string = preg_replace("//i", "",
$string);
echo "$string$new_string";
?>
preg_replace = regular expression replacement
.* is greedy... Match any character . as many times * as necessary, made
less greedy because the ? looks for whatever
Hi Chris,
If you're using MySQL 3.23+, you might want to consider using something
like:
SELECT songname FROM mp3 ORDER BY RAND() LIMIT 1
Not that this answers your original problem, but it seems to make more sense
than manually coding a random number (which is, perhaps, impractical
especiallyif
Perhaps I shouldn't have made the assumption that steph was using mysql :)
"Henrik Hansen" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> [EMAIL PROTECTED] (James Holloway) wrote:
>
> > Hi Steph,
> >
> &
Hi Steph,
as the name suggests, use LIMIT ;)
Ie,
SELECT * FROM TABLE LIMIT 0,25
The 0 (or other number) is optional, and tells the table which row to start
limiting from, the secon number is the number of rows to limit to.. So:
SELECT * FROM TABLE LIMIT 25,25
Would bring out 25 rows, startin
Hi Dan,
maybe something like:
$newvariablethatwewantbetweenthetags = "Long variable!";
$string = preg_replace("/()(.*?)(<\/TAG>)/i",
\\1$newvariablethatwewantbetweenthetags\\2, $string));
There should be a " after and before the second part of that statement, but
my email proggy strips them.
Hi Justin,
for the username, you can use:
if (!preg_match("/^[a-z0-9]*$/", $username)) {
// error
} else {
// ok
}
The ^ means start of the string, the characters between the [ and ] are ones
that we want, the * means however many times, and the $ means the end of the
line / string. So
Better still, use the date("t"); to find out how many days are in the given
month. This part of the date function is a blessing, given the varying days
in months, and the fact that we've a leap year every four years.
James
"Daniel Rezny" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">ne
Hi Mark,
yes it's possible, but with javascript rather than php Do a search on a
javascript related site for window.frames
James.
"Mark Lo" <[EMAIL PROTECTED]> wrote in message
000701c11021$c66111a0$caccfea9@Mark">news:000701c11021$c66111a0$caccfea9@Mark...
> Hi,
>
> I would like to kn
Thanks for your comments, Miles. To answer your question(s), I'll not be
wanting to select multiple categories in anything other than the
administration section. The main search form has the categories listed, and
the user only has the option to select from one category.
The reason I need to be
Hey guys,
I saw a post in here the other day that's prompted me to ask this
question... Because I can't seem to get the solution mentioned to work.
Maybe I'm missing something obvious... Anyway, here goes.
I have a list of categories contained in one table, and a list of entries in
another. S
Hi Shawna
Look up preg_replace();
Assuming $file is the contents of your file -
$file = preg_replace("//i", "", $file);
James.
<[EMAIL PROTECTED]> wrote in message
BB6D932A42D6D211B4AC0090274EBB1D2EEF63@GLOBAL1">news:BB6D932A42D6D211B4AC0090274EBB1D2EEF63@GLOBAL1...
> I've created a "printer-
You're right, I did...
Still suffering from the effects of a manic dentist this morning. ;)
James
- Original Message -
From: "Adrian Ciutureanu" <[EMAIL PROTECTED]>
To: "James Holloway" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: W
Hi Jeff,
Yes, use time()
Example 86400 seconds in a day. 3600 in an hour. Use some basic
maths:
$cookie_expire = time() * 86400 * 365; // Sets cookie for a year (365 days).
James.
"Jeff Lewis" <[EMAIL PROTECTED]> wrote in message
006101c10a08$874f93c0$76a1a8c0@LEWISJCIT">news:006101c10
*Shrug*
Don't have time to test at the moment... That was taken from Chapter 9.3.4.7
of the MySQL manual
http://www.mysql.com/doc/P/a/Pattern_matching.html
Prior to MySQL Version 3.23.4, REGEXP is case sensitive, and the previous
query will return no rows. To match either lowercase or upper
Hey try this, though there are probably better ways,
"SELECT * FROM foo WHERE name REGEXP '^[PHP]'";
James
""Bass¨Ð¦õªv"" <[EMAIL PROTECTED]> wrote in message
9egfot$cfu$[EMAIL PROTECTED]">news:9egfot$cfu$[EMAIL PROTECTED]...
> Hi ,
> By defualt , select rows from Mysql is case insenstive .
> F
Hey,
Simple solution:
" . stripslashes(htmlentities($name)) . "\n\n" .
stripslashes(htmlentities($description)) . "\n";
}
?>
James.
""YoBro"" <[EMAIL PROTECTED]> wrote in message
9eg0jl$5ac$[EMAIL PROTECTED]">news:9eg0jl$5ac$[EMAIL PROTECTED]...
> Hi,
>
> Any ideas, or any code that will allo
Dennis,
NOT tested:
$string = preg_replace("/^(\$|\\\|\/|\.)/i", "", $string);
James.
"Dennis Gearon" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Could someone please send me the code for doing the above? I have the
> book, "Mastering Regex, blah blah",
Hi Sam,
> The following is exactly what I typed in (just copy and pasted) but I'm
> still getting the error:
>
> Cannot add header information - headers already sent by (output started at
> web.php:2) in
> web.php on line 19
Make sure that all output for Cookies and header information is sent b
Hiya Plutarck,
The .*'s are greedy. Maybe you should do something like this (not tested):
$file = preg_replace("/(])*([^<])*(<\/script>)/i", "", $file);
That should replace something like:
Some (code not<)
with
James.
""Plutarck"" <[EMAIL PROTECTED]> wrote in message
9eb4nf$pdf$[EMAIL PR
Hi Mark,
> > It's nice in that it adds to how secure PHP code is, but it can be a
> hassle.
>
> Out of curiousity, what are the security implications? Presumably a
failure
> to validate input properly leading to unintended actions, but I can't
think
> of any examples to help me decide whether to
Hi Sandeep,
preg_match();
ereg();
eregi();
Will all help you.
James.
"Sandeep Hundal" <[EMAIL PROTECTED]> wrote in message
A0A5617A0A05D5118EBD00508B8B953B5EA932@PROF-X">news:A0A5617A0A05D5118EBD00508B8B953B5EA932@PROF-X...
> hi all!
>
> i need to see if a $variable has a piece of text inclu
Hi Henry, I'm not too familiar with Cron, but check the man pages for cron
and crontab (type 'man cron' or 'man crontab', or type 'man man' if you've
not used man pages before).
James.
""Henry"" <[EMAIL PROTECTED]> wrote in message
018b01c0e19d$544818a0$046265cb@henry">news:018b01c0e19d$54481
Gah! Forgot an element for that form: Page element.
">
:)
> Hi Richard.
>
> Two methods, POST and GET: Post for forms and best works with hidden
> elements.
>
> Get can be put across URL's:
>
> echo "Next";
>
> Or
>
> " METHOD="POST">
> " VALUE=" ?>">
>
>
>
> Of course form buttons look d
Hi Richard.
Two methods, POST and GET: Post for forms and best works with hidden
elements.
Get can be put across URL's:
echo "Next";
Or
" METHOD="POST">
" VALUE="">
Of course form buttons look dreadful, so if you use that method, create a
graphic to use, or do a javscript work around for
Hi There,
I had a similar problem because of BST (British Sumer Time). Have a look on
Yahoo / Google etc for a site about Greenwich Mean Time, and find out the
dates that the schemes take effect - I think it is March 25th to beginning
or end of October. Then use a simple if statement.
3) && (
In addition - if you did 3rd June as the end date - 17th May as today, 3 -
17, the original $days_to_go would be a minus number (What I meant to
say in the first place
Also, this would be better:
if ($date_today > $school_out) {
echo "We're already on holiday!";
$new_difference = $da
Neither will work. Think about it.. If you did 17 - 3 (17th May - 3rd
June) - you get 14. But if you add 14 days from today, you get 31st May,
which is clearly wrong. What if there are 30 days in the month instead of
31? Or 28? Or even more obscurely 29? You cannot rely on this method at
Hi Laurie,
If the data to be displayed was in a database, and each row of data
corresponded to an auto incrementing id, you could reference by id number,
which is a much better way of doing things via the GET method than messing
around with long names. Assuming that you have two tables, one that
>From phpinfo() on f2s.com
upload_max_filesize 2M
So, something like,
@copy($file, "/path/to" . $file_name)
or die ("Blam, something's up!");
should work - haven't got time to try it at the moment.
James.
> What am I doing wrong here?
> Is there a way to get around the temporary folder?
Hi Christian,
I have an account with f2s.com that I use for sampling scripts with - I set
up a mailform yesterday after reading this, using mail() to send the email
to myself. It got here - albeit 6am today (I sent it yesterday
lunchtime) Perhaps you're using the mail() function incorrectly
Hi Bill
]{1,})*([\>])/i", $string)) {
echo "Houston, we have a problem.";
}
?>
James.
"bill" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Is there a way to detect the presence of HTML tags?
>
> I don't want them stripped out, I just want to know if a
Hi Richard,
I *always* get this word wrong, but here goes You need to
"concantenate" (grimace), which means (simply) "add to" to the variable,
using .=
Modify your code slightly:
Notice the .= before $recipient = $email ?
Also why, is the $num_rows in there? It's not being used for
Hiya Taz,
James.
"Tarrant Costelloe" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have a log in script written in PHP4 which accesses a secure server.
Once
> entered I want the the secure page to hold the users name (from variable)
in
> the header ..
Hi Matthias,
well, for starters, from that code snippet your max upload size is less than
a kilobyte. So "large files" will not even stand a chance of getting
copied. Remeber that 1024 bytes is 1Kb, so if you wanted to limit to 100Kb,
the max_upload would be 102400. You ideally need to specify
Steve,
The way you are doing things could leave yourself open with all kinds of
problems - one of which is address spoofing. A better way would be to TEST
the link against values in the database before updating the link with a hit
and exiting. Have the URL's marked against an auto-incremented i
Jacob,
When you upload a file, it appends a few of its own variables. One of them
is size - assuming the file is a variable called $file:
if ($file_size > $max_size) {
echo $file_name . " was too big!";
}
Also, you could check for Mime types.
if ($file_type != "image/jpeg" || $file_type !
Gary,
Yes. Check the manual for mktime(); and getdate();
http://www.php.net/quickref.php
James
> Is there a way to do calculations with dates? Preferably ignoring
weekends.
>
> Thanks, Gary
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
>
Magnus,
$string = stripslashes($string);
http://www.php.net/manual/en/function.stripslashes.php
James.
""magnus lawrie"" <[EMAIL PROTECTED]> wrote in message
9cu11s$6k1$[EMAIL PROTECTED]">news:9cu11s$6k1$[EMAIL PROTECTED]...
> I am using a form to test posting a variable. If my variable looks l
Jon,
Try this ... I know the code could be trimmed down, but I wrote it this way
for ease of reading.
";
echo "$month/$day/$year";
echo "\n";
$startperiod = $startperiod + 86400;
}
?>
Basically just uses mktime() and getdate()
The 86400 is the number of seconds in the day, and the opti
One thing that doesn't seem to have been considered is the use of the
"refresh" meta tag. Whilst it depends on whether or not the browser is
archaic (and let's face it, most people nowadays seem to be running at least
version 4 of either IE or Netscape), it's something that can't be turned off
(a
Hi There,
I currently have a MySQL table, with around 700 populated rows in it. I'd
like to know if there's a quick and easy way to update one column across all
of the rows in the database. I shouldn't imagine it's a difficult job, but
I'm having a mental block :)
Thanks in advance.
--
James
Glen Scott <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> James,
>
> The trouble is, that there are about 3000 cities in the text file. I'm
> >assuming that I fill use fopen(); and fread(); to open and read the
files,
> >but does anyone know of a way of singl
Hi all,
I'm attempting to write a weather script, which will display weather
conditions for areas in the UK.
I have the data I need, which is stored in a file on another server. The
data comes in the format:
2001/01/16 13:50
SCT010 BKNDPIP WYXWE Q1012
2001/01/16 13:46
CYGL 161346Z 34004
55 matches
Mail list logo