Machine Nation
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Machine Nation

Irish Politics Forum - Politics Technology Economics in Ireland - A Look Under The Nation's Bonnet


Devilish machinations come to naught --Milton
 
PortalPortal  HomeHome  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  GalleryGallery  MACHINENATION.org  

 

 MySQL question

Go down 
Go to page : 1, 2  Next
AuthorMessage
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: MySQL question   MySQL question EmptyThu Sep 04, 2008 12:23 am

I want to INSERT a string into a db with command line.

The string has apostrophes and commas.

But these are used for field delimiting.

How do I get around that. Do I have to use escape characters ??
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 1:15 am

OK, figured it out.

string mysql_string_escape(string) does the job nicely. Smile
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 1:26 am

EvotingMachine0197 wrote:
OK, figured it out.

string mysql_string_escape(string) does the job nicely. Smile

So this would be MySQL answer?
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 1:42 am

EvotingMachine0197 wrote:
OK, figured it out.

string mysql_string_escape(string) does the job nicely. Smile

Or for shorter strings (say, just the name O'Neil) use a backslash - O\'Neil.
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:04 am

Thanks ibis.

That php function is also escaping double quote(")

So if the string contains html e.g.
Code:
<td align="center">...
the query will be
Code:
INSERT into blah  bla blha VALUES ('<td align=\"cente\r">.......),

So then when this is dumped back out to a browser, it should read properly again ??


Last edited by EvotingMachine0197 on Thu Sep 04, 2008 2:08 am; edited 2 times in total
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:06 am

Ard-Taoiseach wrote:
EvotingMachine0197 wrote:
OK, figured it out.

string mysql_string_escape(string) does the job nicely. Smile

So this would be MySQL answer?

Laughing Now I get it. I'm a bit slow tonight. Most of answer.
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:06 am

MySQL is a software system for databases, is it not?
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:11 am

Ard-Taoiseach wrote:
MySQL is a software system for databases, is it not?

It is. SQL is a microsoft version and MySQL is an open source version from Sun microsystems...I think.
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:13 am

EvotingMachine0197 wrote:
Ard-Taoiseach wrote:
MySQL is a software system for databases, is it not?

It is. SQL is a microsoft version and MySQL is an open source version from Sun microsystems...I think.

I see, and because it's open source you can play around with it to a much greater extent than prefabricated MS versions?
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:22 am

Quote :
It is. SQL is a microsoft version and MySQL is an open source version from Sun microsystems...I think

Actually, SQL is the language - Structured Query Language - used to talk to most databases. Microsoft's database server software is called "SQL Server", and a big fat dog of a yoke it is too.

EvotingMachine0197 wrote:
Thanks ibis.

That php function is also escaping double quote(")

So if the string contains html e.g.
Code:
<td align="center">...
the query will be
Code:
INSERT into blah  bla blha VALUES ('<td align=\"cente\r">.......),

So then when this is dumped back out to a browser, it should read properly again ??

If it doesn't, you can use the php stripslashes() function to remove them. You don't really need slashes before the double quotes anyway - only the single quotes are meaningful in SQL.

If you're working on a server you have full control over, you can set the magic_quotes_gpc to on parameter in the php.ini file. However, it is better to use mysql_real_escape.
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:23 am

Well...I suppose SQL is more a language for talking to a DB, than a DB itself. So I'm really playing around with the language trying to get info in and out of the db in the correct format and in the right place.

I think most web development is open source now.

Linux operating systems
Apache File servers
MySQL database admin
PHP server scripting.

People who regularly indulge in all 4 are called LAMP programmers.

I just potter about with the bottom two, as I am quite the amateur, and make no crust out of it. Thank God.
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:23 am

Ard-Taoiseach wrote:
EvotingMachine0197 wrote:
Ard-Taoiseach wrote:
MySQL is a software system for databases, is it not?

It is. SQL is a microsoft version and MySQL is an open source version from Sun microsystems...I think.

I see, and because it's open source you can play around with it to a much greater extent than prefabricated MS versions?

If you have the yen to rewrite the software, yes. However, it's also a lot faster, and free in most forms of use.
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:26 am

EvotingMachine0197 wrote:
Well...I suppose SQL is more a language for talking to a DB, than a DB itself. So I'm really playing around with the language trying to get info in and out of the db in the correct format and in the right place.

I think most web development is open source now.

Linux operating systems
Apache File servers
MySQL database admin
PHP server scripting.

People who regularly indulge in all 4 are called LAMP programmers.

You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMP programmer.

EvotingMachine0197 wrote:
I just potter about with the bottom two, as I am quite the amateur, and make no crust out of it. Thank God.

I do. It's fun...
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:27 am

ibis wrote:


If it doesn't, you can use the php stripslashes() function to remove them. You don't really need slashes before the double quotes anyway - only the single quotes are meaningful in SQL.

If you're working on a server you have full control over, you can set the magic_quotes_gpc to on parameter in the php.ini file. However, it is better to use mysql_real_escape.

Yeh, I have full control, and also have phpMyAdmin on there so I can see what's going on after the insert queries. I'll see how I go tomorrow evening. I'm going to sleep(); now.
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 2:30 am

ibis wrote:
EvotingMachine0197 wrote:
Well...I suppose SQL is more a language for talking to a DB, than a DB itself. So I'm really playing around with the language trying to get info in and out of the db in the correct format and in the right place.

I think most web development is open source now.

Linux operating systems
Apache File servers
MySQL database admin
PHP server scripting.

People who regularly indulge in all 4 are called LAMP programmers.

You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMP programmer.

Oh yes, I've heard of that. I feel safer to keep well away.

Quote :
EvotingMachine0197 wrote:
I just potter about with the bottom two, as I am quite the amateur, and make no crust out of it. Thank God.

I do. It's fun...

I know you do. It is fun, but in small doses. Smile
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyThu Sep 04, 2008 11:26 pm

EvotingMachine0197 wrote:
Well...I suppose SQL is more a language for talking to a DB, than a DB itself. So I'm really playing around with the language trying to get info in and out of the db in the correct format and in the right place.

I think most web development is open source now.

Linux operating systems
Apache File servers
MySQL database admin
PHP server scripting.

People who regularly indulge in all 4 are called LAMP programmers.

I just potter about with the bottom two, as I am quite the amateur, and make no crust out of it. Thank God.
I must really be a lamplighter, because I can add Perl, Python, Flash Graphics Design, Actionscript, ObjectC, Squeak SmallTalk, and of course the oldies, Fortran, C, C++, Rexx, Pascal, Basic, oh! and Blender the 3-d Graphic Design system, and of course Mathematica, Linpack,... oh. when will I stop bragging. Very Happy

I
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 12:56 am

ibis wrote
Quote :
You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMPy programmer.

This playing around with computer languages is fun afterall... Wink
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 2:04 am

Kate P wrote:
ibis wrote
Quote :
You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMPy programmer.

This playing around with computer languages is fun afterall... Wink

Very Happy

No really though, it is fun. Unless it simply refuses to work, then it's a feckin pain.

The more PHP I learn, the more I am staggered by what it can do in simple commands, which could have taken 2000 lines of code just 15 years ago. Great stuff. Basketball
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 2:20 am

Kate P wrote:
ibis wrote
Quote :
You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMPy programmer.

This playing around with computer languages is fun afterall... Wink

Cheeky - I'll have you know you're using my intellectual property there, and modifying it without my permission. I coined WIMP back in 2001, during a training course I was running!
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 2:28 am

ibis wrote:
Kate P wrote:
ibis wrote
Quote :
You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMPy programmer.

This playing around with computer languages is fun afterall... Wink

Cheeky - I'll have you know you're using my intellectual property there, and modifying it without my permission. I coined WIMP back in 2001, during a training course I was running!

Well then , coiner of WIMP, is it possible to leave a continuously running PHP script on a host server ? ie. if I make a script that say .. has to load 10000 website homepages in turn and search for a string - and if (string exists) {save url to file}

This could take hours conceiveably (spell) ?

Is it normal for a host server to put a time limit on execution time ?
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 3:20 am

EvotingMachine0197 wrote:
ibis wrote:
Kate P wrote:
ibis wrote
Quote :
You can also use (as I often do) Windows-IIS-mySQL-PHP, which makes one a WIMPy programmer.

This playing around with computer languages is fun afterall... Wink

Cheeky - I'll have you know you're using my intellectual property there, and modifying it without my permission. I coined WIMP back in 2001, during a training course I was running!

Well then , coiner of WIMP, is it possible to leave a continuously running PHP script on a host server ? ie. if I make a script that say .. has to load 10000 website homepages in turn and search for a string - and if (string exists) {save url to file}

This could take hours conceiveably (spell) ?

Is it normal for a host server to put a time limit on execution time ?

There's usually a 30-second limit in the php.ini file under max_execution_time. Ideally, you change that to a value in seconds sufficient to give you time - on my development system, mine is set to 2400 (I used to have it set to 30000, which is 8.33 hours). I don't think there's a maximum.

You can also use set_time_limit in the script itself (see here). That's sometimes a more sensible approach, because if you allow any script to run for as long as it likes, your next infinite loop will involve major pain.

An alternative which I sometimes use is to break the job up into batches, and execute the page in a browser window. When the script is finished its batch, I make it echo "document.location='script.php?batch=2'" to get the browser to automatically pass on to the next batch in the sequence - 2, 3, 4, etc.

Assuming you're writing the result of the search to database, any failure of the script is recoverable - you just start from the last recorded point in the process.
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 3:31 am

OK ibis. I went looking for php.ini, and I cannot alter it. Well I can if I ring th hoster .

Quote :

These PHP configuration settings are customizable by the server administrator. They are listed for reference only.

Sub Section Directive Info Value
Language Options asp_tags Allow ASP-style <% %> tags. Off
File Uploads file_uploads Whether to allow HTTP file uploads. On
Paths and Directories include_path Windows: "\path1;\path2"
c:\php\includes"
.:/usr/lib/php:/usr/local/lib/php
Resource Limits max_execution_time Maximum execution time of each script, in seconds 30
Resource Limits max_input_time Maximum amount of time each script may spend parsing request data 60
Resource Limits memory_limit Maximum amount of memory a script may consume (32MB) 32M
Data Handling register_globals You should do your best to write your scripts so that they do not require
register_globals to be on; Using form variables as globals can easily lead
to possible security problems, if the code is not very well thought of.
Off
Language Options safe_mode
Off
main session.save_path where N is an integer. Instead of storing all the session files in
/path, what this will do is use subdirectories N-levels deep, and
store the session data in those directories. This is useful if you
or your OS have problems with lots of files in one directory, and is
a more efficient layout for servers that handle lots of sessions.
NOTE 1: PHP will not create this directory structure automatically.
You can use the script in the ext/session dir for that purpose.
NOTE 2: See the section on garbage collection below if you choose to
use subdirectories for session storage
N;/path
File Uploads upload_max_filesize Maximum allowed size for uploaded files. 2M

So it is set to 30 seconds. Shite. Now I have a problem.
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 3:33 am

So now I have to learn how to do a batch job - phpwise. No
Back to top Go down
Guest
Guest




MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 4:00 am

EvotingMachine0197 wrote:
OK ibis. I went looking for php.ini, and I cannot alter it. Well I can if I ring th hoster .

So it is set to 30 seconds. Shite. Now I have a problem.

Hmm. Try using set_time_limit in a test script. Set it for some largish but not too insane value - say 300 seconds (5 minutes). Run the script, and see if it times out in the 30 seconds or the five minutes. If the latter, problem solved.

The set_time_limit instruction goes in the script itself:

<?
set_time_limit(300);

for($i=0;$i<1000000000000;$i++){
...some time wasting...
}
?>

Or sleep(300) of course!
Back to top Go down
Ex
Fourth Master: Growth
Ex


Number of posts : 4226
Registration date : 2008-03-11

MySQL question Empty
PostSubject: Re: MySQL question   MySQL question EmptyFri Sep 05, 2008 4:19 am

Code:


<html>
<head><title>Timmy</title></head>
<body>

<?php

print "<br/><h2>Time out Exec script</h2><br/>";



set_time_limit(300);

$x=1;

for($i=0;$i<1000000000000;$i++)

{

$x=$x+1;
$x=$x-1;

}


print "script Finished....Sheesh";
?>


</body>
</html>

This is running now. 30 seconds gone.
Back to top Go down
Sponsored content





MySQL question Empty
PostSubject: Re: MySQL question   MySQL question Empty

Back to top Go down
 
MySQL question
Back to top 
Page 1 of 2Go to page : 1, 2  Next
 Similar topics
-
» A Question of VISAs
» Cash and collateral: IL&P, ILA, TSB - a question
» The 64 Billion Euro question - FAQ
» A question I never found the answer to.
» Inflation / Banking / Interest Rate Question.

Permissions in this forum:You cannot reply to topics in this forum
Machine Nation  :: Machine Nation :: Science, Technology, Engineering, Computers-
Jump to: