1. вот так!

    Date: 12/21/05 (Code WTF)    Keywords: database, sql

    public static void isDBConnectionValid(Connection dbConnection)
    throws Exception
    {
    if(dbConnection == null)
    throw new SQLException("Database connection does not exist");
    else
    return;
    }

    Source: http://www.livejournal.com/community/code_wtf/21568.html

  2. Using functions in classes

    Date: 12/22/05 (PHP Community)    Keywords: php, mysql, html, sql, web

    I am learning classes (trying to anyway).

    I have class called photo. It contains two functions:

    create_folder()
    sterilize_text()

    In the create_folder function I want to clean user uploaded data before creating a folder based on that data. I have a few special rules so I wanted to put this in a seperate function instead of regexing all over my pages.

    I read that using functions within functions in classes is easy, but I don't know how and the tutorial I'm using doesn't touch on using nested functions.

    So what happens is when I invoke the class and use create_function(), php exits with this:

    Fatal error: Call to undefined function: sterilize_text() in /var/www/html/includes/classes.php on line 34
    Line 34 is : $brand = sterilize_text($myrow[brand]);

    Is there a way to code this so I can use functions within functions, inside of my class? I've included the relevant scripts below.

    Thank you.


    class photo
    {
    
    	var	$model;
    
    	// mk the folder for an uploaded image.
    	function create_folder($model)
    	{
    
    		global $dbx, $dbxold;
    		if (!isnum($model)||strlen($model)>5) {return(false);}
    		
    		$q = "SELECT brand FROM spec WHERE model='$model'";
    		$result = mysql_query($q,$dbxold);
    		$myrow = mysql_fetch_array($result);
    
    		$brand = sterilize_text($myrow[brand]); 
    
    		if ($brand=="") {return(false);}
    		$webpath = "/images/dirtbikes/$brand";
    		$uploaddir = $_SERVER["DOCUMENT_ROOT"] . $webpath;
    		if (!file_exists($uploaddir)) {
    			mkdir ($uploaddir, 0777);
    			chmod($uploaddir,0777);
    			if (!file_exists($uploaddir)) {
    				echo "

    unable to create directory. :(
    "; return(false); } } $dir_array[] = $webpath; $dir_array[] = $uploaddir; return $dir_array; } function sterilize_text($text) { $hyphen = "_"; $dash = "-"; $text = strtolower($text); $text = ereg_replace('[^a-zA-Z0-9_\\,]', '', $text); $text = ereg_replace('[\\]', $dash, $text); $text = ereg_replace('[,]', $hyphen, $text); return $text; } }






    create_folder($model); 
    
    	echo "
    ";
    	print_r($dir_array);
    	echo "
    "; ?>

    Source: http://www.livejournal.com/community/php/382729.html

  3. RSS to MySQL

    Date: 12/23/05 (PHP Community)    Keywords: php, mysql, rss, database, sql

    Hiya,

    I don't have a shell account and uploads via PHP are disabled on my server and this is why I'm looking for a robust RSS parser which feeds into a MySQL database. Since it's nearly impossible to install anything I'm looking for functions/classes I can use.

    I have been able to get LastRSS to work but this does not use MySQL and writes to a directory. I need to leave that directory set to 777 - which is, clearly, no good.

    I've lost faith in the RSS parser I wrote. It glitches too often.

    Does anyone have any recommendations?

    Source: http://www.livejournal.com/community/php/383211.html

  4. First asp.net page - debugging help

    Date: 12/23/05 (Asp Dot Net)    Keywords: database, asp, sql, microsoft

    I'm working on my first asp.net page and am running into some problems. I'm trying to read data from an MS Access database. I'd appreciate if anyone could point me in the right direction - I pretty much lifted the example code from w3schools. Thanks for any help, I'm feeling a bit lost!

    The code below gives an error on line 4, character 5 - expected ";".

    [%@ Import Namespace="System.Data.OleDb" %>
    [script runat="server">
    sub Page_Load
    dim dbconn, dbcomm, dbread
    dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=test.mdb")
    dbconn.Open()
    sql="SELECT * FROM values"
    dbcomm=New OleDbCommand(sql,dbconn)
    dbread=dbcomm.ExecuteReader()
    value.DataSource=dbread
    value.DataBind()
    dbread.Close()
    dbconn.Close()
    end sub
    [/script>


    Database:
    filename: test.mdb, resides in same directory as index.asp file.

    table: values
    fields: ID, key, value

    read [s as <.

    Source: http://www.livejournal.com/community/aspdotnet/52113.html

  5. Mini PHP/MySQL Gallery

    Date: 12/28/05 (PHP Community)    Keywords: php, mysql, sql, web

    I'm the webmaster for Devo bootleg archive Booji Boy's Basement, and I'm converting the whole thing to a PHP/MySQL based back end. However, I've run into a bit of a wall trying to figure out how to implement something.

    The DVD pages contain thumbnail screenshot images which link to a full-size screenshot. Here's an example. (Thumbnails are at the bottom.) Some DVD have only 3 shots, some as many as 12. I'd like it to be any number (within reason). However, I've no bloody clue about what would be the best way to implement this in PHP and MySQL.

    So, if anyone can give me suggestions and guidelines, I'd appreciate it. What I'm looking at is a second table just for the screenshots, each with an identifier linking it to an entry in the DVD table, but I hope there's a simpler way.

    Source: http://www.livejournal.com/community/php/383988.html

  6. Duplicate result rows

    Date: 12/28/05 (MySQL Communtiy)    Keywords: mysql, database, sql

    I am trying to make it so this result can be ordered by the last name of the client. However, the name is in another table thus the JOIN LEFT. That part seems to be working OK (I think), but where I am running into a problem is that the results are showing duplicates (example if invoice 10, there are 3 result rows for invoice 10, but only 1 row in the actual MySQL table "invoice_main").

    (Yes, there are some name/case mismatches, but I didnt create the database.)

    Thanks!

    SELECT DISTINCT
    invoice_main.invoice_number,
    invoice_main.invoice_date,
    invoice_main.due_date,
    invoice_main.clientid,
    invoice_main.subtotal,
    invoice_main.paid_amounts,
    invoice_main.payment_status,
    clients.ClientLast
    FROM $TableName
    LEFT JOIN clients ON invoice_main.clientid=clients.ClientID
    WHERE invoice_main.office_id='$office_id'
    ORDER BY $SortParam
    LIMIT $limit,$Limit_increment


    Adding GROUP BY invoice_main.invoice_number gave me an SQL error


    [UPDATE] Figured it out
    LEFT JOIN clients ON invoice_main.office_id=clients.office_id AND invoice_main.clientid=clients.ClientID

    Gotta thank '[info]'jedifreeman and his help with JOIN a couple weeks ago. I was re-reading our AIM conversation and thought of this.

    Source: http://www.livejournal.com/community/mysql/80119.html

  7. Two completely unrelated SQL Server 2005 questions.

    Date: 12/30/05 (SQL Server)    Keywords: sql

    1. In query nalyzer, type either of the following and run it:
    PRINT 365/183
    PRINT CAST(365/183 AS float)

    If your answer is 1 (or 1.0), congratulations, you win. You get to tell me what switch we both need to flip to get the correct (mathematically, anyway) answer.

    * * *

    2. I'm porting a horribly-written Access application to SQL Server. It contains a table with three columns. Each of these columns corresponds to a dropdown box on a form. The way it's supposed to be written is that a value selected in column A will populate the list in column B, etc., since only certain values in column B should be present for any given value in column A. The monkeywrench in the works is that the values in B are not necessarily unique to the values in A, and the values in C are definitely not unique to the values in B-- but not all values in B are applicable to all values of A, and all values in C are not etc. As an example:

    A: Inpatient, Outpatient, Other
    B: Transplant, Maternity, Addiction Treatment
    C: Bone Marrow Transplant Allogenic, Caesarian Section, Emergency Room

    It's relatively obvious that Outpatient in A will never correspond to Transplant in B; Transplant will always, short of a medical miracle, be an inpatient procedure. Addiction Treatment, though, can be on either an inpatient or outpatient basis. (I'm lobbying for getting rid of "other" altogether.) Similarly, Bone Marrow Transplant Allergenic will, good lord willin' and cricks don't rise, never apply to maternity-- but Emergency Room could concievably apply to just about anything in either column A or column B, because you can show up at the ER needing, well, anything.

    What I've been mulling over is having three different lookup tables, each with two columns-- ID and Description-- and a fourth column that would list the valid IDs that can go together for each. That, however, ultimately saves me not much room, will require manual additions to the core table whenever new categories are added, and would probably end up being slower. (Actually, anything will end up being slower, seeing as the Access app takes the Chinese-menu method-- display anything and let the user pick whatever-- but I'd like to cut the speed decrease as much as possible.) We're still in the brainstorming phase with this, so there aren't any ideas which will undercut work that's already been done. If you have any to throw into the ring, I'd appreciate it.

    Thanks!

    Source: http://www.livejournal.com/community/sqlserver/38791.html

  8. syntax error

    Date: 12/31/05 (PHP Community)    Keywords: php, mysql, html, sql

    Ok, I'm being slowly driven nuts by this. There is a syntax error and whatever it is, my eyes are just sliding right past it each time. If anyone can spot it I will be eternally grateful. The error is "
    Parse error: parse error, unexpected ';' in /home/remove/public_html/test/root/admin_functions.php on line 35"

    I have marked the line 35 in red.

    If anyone can think of a better way of doing this (while your here) that would be great. It takes tags much like you would set for an LJ entry, splits them up and then checks the tags table for them, if they aren’t there it then adds them. Then for each tag, it sets up a map in the maptag table which links the page_id to the tag id (the tag id in the tags table is set in an auto_increment, so it have to run yet another query to find this out).

    It doesn’t have to be too fast though, its only admin.

    function update_tags($page_id, $tags_string)
    {
    $tag_array = explode(',', $tags_string, -1);
    $count = count($tag_array);
    for ($i = 0; $i < $count; $i++)
    {
    $update_tags_query = "SELECT `id` FROM `tags` WHERE `name` = '" . $tag_array[$i] . "'";
    $update_tags_result = mysql_query($update_tags_query) or die('update tags query failed: ' . mysql_error());
    if(mysql_num_rows($update_tags_result)==0)
    {
    //add entry to tags table
    $tag_update_query = "INSERT INTO tags (name) VALUES ('" . $tag_array[$i] . "')";
    mysql_query($tag_update_query) or die('tag update query failed: ' . mysql_error());

    //then find out the new tags id
    $tags_query = "SELECT `id` FROM `tags` WHERE `name` = '" . $tag_array[$i] . "'";
    $tags_result = mysql_query($tags_query) or die('tags query failed: ' . mysql_error());
    $tags_array = mysql_fetch_array($tags_result);

    //then add to the maptag table
    $maptag_update_query = "INSERT INTO maptag (contentid, tagid) VALUES (" . $page_id . ", " . $tags_array['id'] . ")";
    mysql_query($maptag_update_query) or die ('maptag update query 1 failed: ' . mysql_error());
    }else(
    //add entries to the maptag table
    $update_tags_array = mysql_fetch_array($update_tags_result);
    $maptag_update_query = "INSERT INTO maptag (contentid, tagid) VALUES (" . $page_id . ", " . $update_tags_array['id'] . ")";
    mysql_query($maptag_update_query) or die ('maptag update query 2 failed: ' . mysql_error());
    }
    }
    }

    Source: http://www.livejournal.com/community/php/386426.html

  9. I'm sure I'm missing something glaringly obvious here...

    Date: 01/01/06 (PHP Community)    Keywords: php, mysql, html, sql, web

    Hi all, I'm a complete and total noob to PHP and MySQL. I'm working on putting up a site/cart for a friend.

    http://www.allthingsally.com

    I'm barely dipping my toes in, I know, I'm using a pre-made cart, that self-installs, has a web-based back-end built in, and should be easier than pie.

    I've managed to get much of the changes made from the demo cart that I wanted to, and now I'm stuck. The pages are all basically built off of a single template, and it's an HTML template at that, so it should be more in my realm of expertise. Now as you can see on the page, there is a graphic/logo that should be displaying on the top, but for the life of me, I can't get it to work. I've stared at it and relinked for about 4 hours now, and I'm getting no-where. Any help/ideas would be swell.

    If this is too vague, or doesn't make any sense, just let me know and I'll elaborate any way I can. I'm sorry if this is beyond stupid.

    Thanks in advance.

    Source: http://www.livejournal.com/community/php/386583.html

  10. Stopwords

    Date: 01/01/06 (MySQL Communtiy)    Keywords: php, mysql, sql

    Ok, new problem.

    I have got my fulltext searches to work, but am very much against the idea of stopwords. many of them I want people to be able to search.

    Now I have tried setting the path of the file containing them to nothing, but my shell access is having an off day (plus I don’t really want to change thing in there).

    Is there a way in the query of letting some of the stopwords pass. I’m using version 4.0.25

    Thanks for any help

    x posted to '[info]'php (because they use mysql too)

    Source: http://www.livejournal.com/community/mysql/80433.html

  11. Stopwords

    Date: 01/01/06 (PHP Community)    Keywords: php, mysql, sql

    Ok, new problem.

    I have got my fulltext searches to work, but am very much against the idea of stopwords. many of them I want people to be able to search.

    Now I have tried setting the path of the file containing them to nothing, but my shell access is having an off day (plus I don’t really want to change thing in there).

    Is there a way in the query of letting some of the stopwords pass. I’m using version 4.0.25

    Thanks for any help

    (i know this is a php group, but not everyone here is part of mysql, but most of you seem to know your way round it (plus, this is for a php search page :D))

    x posted to '[info]'mysql

    Source: http://www.livejournal.com/community/php/387303.html

  12. PHP and MYSQL help

    Date: 01/03/06 (PHP Community)    Keywords: mysql, database, sql

    While trying to connect to the mysql database, I get this error:
    Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    So I look up the solutions for this error. I discover that I need to edit a my.cnf file and change the socket setting. I wish it was that easy. I check what socket is set too.

    [client]
    #password = my_password
    port = 3306
    socket = /opt/local/var/run/mysqld/mysqld.sock

    Not the socket the server is trying to connect to.

    The file is located in /opt/local/etc/mysql4 and I also copied it to /opt/local/etc incase.
    The password and username is correct, I can manually connect to the database.
    Using a Mac OSX.4 server.
    DB Server version is 4.1.15
    Connection: Localhost via UNIX socket

    I am out of ideas, can anyone help me?

    Source: http://www.livejournal.com/community/php/388151.html

  13. PHP and MYSQL help

    Date: 01/03/06 (MySQL Communtiy)    Keywords: mysql, database, sql

    While trying to connect to the mysql database, I get this error:
    Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    So I look up the solutions for this error. I discover that I need to edit a my.cnf file and change the socket setting. I wish it was that easy. I check what socket is set too.

    [client]
    #password = my_password
    port = 3306
    socket = /opt/local/var/run/mysqld/mysqld.sock

    Not the socket the server is trying to connect to.

    The file is located in /opt/local/etc/mysql4 and I also copied it to /opt/local/etc incase.
    The password and username is correct, I can manually connect to the database.
    Using a Mac OSX.4 server.
    DB Server version is 4.1.15
    Connection: Localhost via UNIX socket

    I am out of ideas, can anyone help me?

    Source: http://www.livejournal.com/community/mysql/80709.html

  14. Hello World and a question

    Date: 01/03/06 (SQL Server)    Keywords: database, sql

    Just joined. Looks like a nice comm.

    Quick question:

    I have a production database that is about 1 GB in size. I have been tasked to script that baby out into sql files. The tables, procedures, etc. should be little problem (thanks to the database scripting wizard), but the data is eluding me. How can I (relatively automated) script table data into a series of INSERT statements?

    Is there any way to avoid manually typing:
    "INSERT INTO tbl_WHATEVER (ID, FIELD1, FIELD2, ...) VALUES (1, 1, 1, ...)"?

    Thanks in advance!

    Source: http://www.livejournal.com/community/sqlserver/39390.html

  15. Trouble Deleting Table

    Date: 01/05/06 (PHP Community)    Keywords: php, mysql, sql

    I've tried several variations of code.
    (even direct copy from several sites)

    But I can't seem to delete a table from my php file.
    (works great from directy sql in phpmyadmin)

    Here is the code I am working with (connection already made to db)

    Any ideas? Thanks!

    -----

    $tblname = "tablename";

    $result = @mysql_query("DROP TABLE '$tblname'");
    if (!$result)
    {
    echo ("Error--Unable to Delete Table. Try Again Later");
    exit;
    }

    Source: http://www.livejournal.com/community/php/389160.html

  16. File Serving

    Date: 01/06/06 (PHP Community)    Keywords: php, mysql, html, sql, web

    So what is the best way to serve documents (DOC PDF Images, other…) from a location outside of your public html directory?

    I thought about using mysql and the LONGBLOB attribute.

    But surely there must be a way to simply store the files and use php to retrieve them????
    (I’ve done more web searching than I care to admit)

    Source: http://www.livejournal.com/community/php/390051.html

  17. gfd

    Date: 01/05/06 (PHP Community)    Keywords: mysql, database, sql, web

    Okay, stumped.



    Everything works fine until the else portion is reached. At that point, the query that is echoed works just fine if I paste it into my MySQL db, but it acts like an asshole here, apparently, because I get the old "not a valid resource" error message that we all live for. It should only be selecting one record, the one with the corresponding ID number (there are no duplicate IDs) and then displaying the information associated with that ID number after obtaining the ID number from the url as a $_GET. (I know there's some unnecessary variable re-setting in here - I was trying anything I could.)

    I can't figure this out. It's something so simple, I bet, and that's why I'm not seeing it because I've been swearing at it for over 30 minutes now.

    Any help is appreciated.

    Source: http://www.livejournal.com/community/php/389386.html

  18. Boston MySQL Meetup Group

    Date: 01/06/06 (MySQL Communtiy)    Keywords: mysql, sql, google

    The MySQL Meetup group meeting on Monday, January 9th will focus on backups -- I will give a 30-45 minute presentation on backups and we will then delve into a discussion -- how folks within the group are backing up, how they're not backing up, how they'd like to back up. If there's time, we'll do a "lessons learned from backup horror stories".

    Afterwards, we'll head a few doors down to Boston Beer Works for more chatting.

    You can see a video of last month's presentation by Philip Antionades of MySQL AB on the new features in MySQL 5.0 at Google Video:

    http://video.google.com/videosearch?q=Mysql+5.0+by+Philip+Antoniades

    (we will video this month's presentation but not the discussion)

    More details, including the event location and directions, are at: http://mysql.meetup.com/137/events/

    I encourage you to sign up to receive notification of events, and participate in discussions outside of the meetups. I won't always be posting here.

    Any questions, comments, etc should be sent to me. We're currently looking for a space better than North Station -- something around MIT might be nice, and we're trying to get an MIT grad student/faculty/staff member/organization to sponsor it. (We want a location that's good for people driving AND taking the T, and when the Garden has an event, it's not feasible to park there). If you can help out, please let me know.

    (You may forward this announcement to other groups, lists, blogs, whatever.)

    I'm quite excited about the presentation, as I'm writing down a lot of information from different sources that really wants to be together, but as far as I can tell is not yet, at least not in a public place.

    Source: http://www.livejournal.com/community/mysql/81107.html

  19. Help?

    Date: 01/09/06 (PHP Community)    Keywords: php, mysql, sql, web

    First off, new to this community so I hope this is okay :)

    Hello, I tried creating my own php based script... and lets face it that was a mess haha (I had so many errors, it was sad really). I've been looking all over the web (literally, I've emailed 20+ people by now) and no one seems to be able to create this project that I am doing (although, one did reply but they were asking for over $500 which I can't afford :/). Basically I'd like a script created, for a project I was hoping on opening a month ago (that went well eh?). Of course I can pay, but I don't have too much money but I'm sure something could be worked out. If interested a discription of what I'd like done (or something similar) will be in the cut below. Thanks in advance, if more detail is require that is fine.


    I am creating a project for my up-and-coming forum (despair.nu) where when members join they can take
    part in different projects. Project will be like that of xposure.nu (might still be down, sorry)

    The project that I need some help on, is creating a php/mysql script where when members join this project they are then approved by having a certain type of link placed on their site. Then a few days a week members are sent random emails containing the user ID, user site address, and user site name and then they must comment on the 3 sites they are sent. Would also like to have it where the emails also contain the comments that the members are supposed to recieve. Also wouldn't mind having some sort of report system, so if someone doesn't comment they can report the member and then member will recieve some sort of warning.Thanks for your time. I was also curious as to 1) How much this project would cost (if you can do it)? and 2) What payment methods you accept (i.e. paypal etc)?.
    Thanks for your time


    Thanks for those who have read this, that's at least something in my opinion (as cheesy as it sounds). Comment here if interested, or email works as well. Thanks again. Or if someone could point me in the direction of either, learning how to do it myself (which I doubt but, hey call it wishful thinking) or of someone who could possibly do it.

    Source: http://www.livejournal.com/community/php/391284.html

  20. Database insert parameters.

    Date: 01/09/06 (C Sharp)    Keywords: database, sql

    Okay, I'm stumped.

    I'm using Intersystems Cache, for which there seem to be no peer help fora anywhere on the net, though theoretically it shouldn't matter, should it? ODBC is ODBC, I hope. In any case, here's a quick code snippet:



           private void btnSave_Click(object sender, EventArgs e)
            {
                try
                {
                    string InsertString = "INSERT INTO Erasmus.Publisher(Name, PublisherURL) VALUES(@Name,@URL)";
                    ErasmusTransaction = ErasmusConnection.BeginTransaction(IsolationLevel.ReadCommitted);
                    ErasmusInsertCommand = new OdbcCommand(InsertString, ErasmusConnection, ErasmusTransaction);
    
                    OdbcParameter prmName = new OdbcParameter();
                    prmName.Direction = ParameterDirection.Input;
                    prmName.OdbcType = OdbcType.VarChar;
                    prmName.Value = txtName.Text;
                    prmName.ParameterName = "@Name";
                    ErasmusInsertCommand.Parameters.Add(prmName);


    I've also tried it with:

           private void btnSave_Click(object sender, EventArgs e)
            {
                try
                {
                    string InsertString = "INSERT INTO Erasmus.Publisher(Name, PublisherURL) VALUES(@Name,@URL)";
                    ErasmusTransaction = ErasmusConnection.BeginTransaction(IsolationLevel.ReadCommitted);
                    ErasmusInsertCommand = new OdbcCommand(InsertString, ErasmusConnection, ErasmusTransaction);
    
                    ErasmusInsertCommand.Parameters.Add("@Name", OdbcType.VarChar, 100).Value = txtName.Text;


    (hope that formats right.)



    Just before we get to the actual query, I've got a messagebox showing ErasmusInsertCommand.CommandText. "@Name" and "@URL" are not switched with the contents of the text boxes on the form (though in all honesty I'm not sure if they should be; perhaps I should be checking the parameter values?). The transaction is rolled back, because the insert command fails. The beginning of the error message (I don't get the whole thing in the message box) is:

    ERROR [42000][Cache ODBC][State:37000][Native Code 12]
    [C:\Documents and Settings\[etc.]]
    [SQLCODE: -12: A term expected, beginning with one of the following: identifier, constant, aggregate, $$, :, (, +, -, %ALPHALP, %EXACT, %SQLSTRING, %SQLUPPER, %STRING, or %UPPER]
    [Cache Error: SYNTAXerrdone+1^%qaqqt]
    [Details: Prepare]

    I've left out some greater-than and less-than symbols in order not to confuse LJ.

    Despite what I see in the error message, I am hoping against hope this is a generic error message, and someone's gotten it on another database (or that someone here works with Cache). All I get from the Intersystems docs about is is an error reference that gives me the same message, and not what I can do about it. If anyone has any ideas, I'm at my wits' end with this...

    oh, yeah: C# 2005 Express Edition, .Net 2.0.

    Thanks.

    Source: http://www.livejournal.com/community/csharp/46500.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home