Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Is there any auto add PHP script?

  1. #11
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    EDIT:
    Just saw your post.
    Ok... you're making this WAY too complex.
    You don't need php. Forget about it.
    You just need notepad/word and do a find/replace to put that in there. couldn't be easier. Really.
    FIND: INSERT INTO
    REPLACE WITH: <query>INSERT INTO
    FIND: ');
    REPLACE WITH: ');</query>

    You're done. Be happy.


    //EDIT



    mysql results are retrieved using mysql queries.... a query is a type of request/database command that results in... well... results.

    (for this example, I'll assume we're using a database for a forum such as this one)

    PHP Code:
    mysql_query("SELECT `name` FROM `members` WHERE `id`='1'"
    That would result in the membername of the first person to get an ID, likely the admin, etc.

    SELECT means... select/grab/get/find/retrieve. `name` means it will select the `name`... not the ID, not the IP address, etc.
    FROM specifies the table in the database... members? topics? private messages? etc...
    WHERE is a condition and optional. You can specify that if you want to find a particular item, or sets of items, like WHERE `group` = "admin".

    Here's what to do with the result:
    PHP Code:
    $result mysql_query('somethinghere');
    while (
    $row mysql_fetch_assoc($result)) {
    echo 
    $row['name']."\n";

    This means...
    The first part sets $result to the value of what is returned from the query. It's some strange form of data that can't be used directly.
    We use the function mysql_fetch_assoc, just a function, don't be alarmed, to make that into an array.
    $row = mysql_fetch_assoc($result) sets the value of ONE row of the result from the query to the $row array.
    If you had more than one result from the mysql query, you would be able to access all of those values in it.
    $row['fieldname'] is the general syntax for a value in the array at tha point, in this case, name... $row['name']
    So... to recap, so you're not lost: 1. ask the database for results that match certain requirements. 2. Take those results and place them into a variable.
    The next step is to use a while loop. This will keep looping/repeating until the rows are over. It's not "while this is equal to this" but literally "while this is set to this".
    Since there are a limited number of rows returned (even if that is a thousand, like you'd be dealing with), then it would fail after the rows are used up. therefore, it loops through all of the rows returned from the database.

    echo is a general command meaning print/output/write to the outputted html.
    echo $row['name']."\n"; means...
    1. print the value of the name from the database, then 2. add a line break (
    \n is a special line break character in php, long story).

    and that's it.

    You may be a bit confused, but it'll make sense.

    That's why I gave you a link.

    Click. Read. Try. It'll work out. that's how I learned. Very easy to follow step by step guide. Heck, it's almost boring in parts it's so easy



    Also, a general question... you may not even need to do this. do you have a text document containing all this information? It looks to me like you have a text backup, which is basically a set of mysql commands to recreate the database, with INSERT INTO, and UPDATE and such.
    If that's the case, then FORGET everything about php and all that.
    You just need to use php to interpret the data, or even use another language. Find/replace in notepad/word/etc. might be able to help.

    I'm still not quite sure what you're doing.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #12
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    EDIT:
    Just saw your post.
    Ok... you're making this WAY too complex.
    You don't need php. Forget about it.
    You just need notepad/word and do a find/replace to put that in there. couldn't be easier. Really.
    FIND: INSERT INTO
    REPLACE WITH: <query>INSERT INTO
    FIND: ');
    REPLACE WITH: ');</query>

    You're done. Be happy.
    WOW....it was that easy . oops. I guess i forgot to learn the father of all computers, the NOTEPAD

    Quote Originally Posted by djr33
    I'm still not quite sure what you're doing.
    http://famousmuslims.muslimonline.org. if you see the Quran there, i made that module for Joomla. I want other people with joomla sites to be able to install and thus need an XML file for those people who dont understand MySQL commands


    Thanks alot djr33. This forum has helped me out in so many problem i have had in my coding life, and unlike others, i actually get help that works. Thanks alot everyone .

  3. #13
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure. Just sorry I missed that.
    You obviously had a text backup of a database, not an active database you could access with PHP. Should've noticed sooner.

    Glad it works


    EDIT: Additionally, I'm not sure how all this works, but I think you can actually have multi-item queries. You might not need a tag between each item... just one at the start and end... and a semi-colon between? Or something. I think there might be a way. But if that works, great.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #14
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Heres how it works.
    <install>
    <queries>
    <query> query here </query>
    <query> query here </query>
    </queries>
    </install>

    If there is a way to multi do it, i wouldnt do it cause it would be too much on the server. im talking about 13000 queries here. no joke. having them all done at once can freeze the upload.

  5. #15
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    sure, that's fine.
    I just mean that I think mysql might support many queries as one... with a semi colon or something, but i'm not sure. so you'd only need the one <query></query> pair. But I don't reallly know.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •