www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 30 of 30

Thread: Not using temporary tables correctly.

  1. #16
    Join Date
    Jan 2014
    Posts
    27
    Quote Originally Posted by blasphemy View Post
    Before running this, call 'DROP TABLE temp' in PHPMyAdmin, because you have created table 'temp' in PHPMyAdmin, I think.
    Ok, I think I should start all over again, cos I am gettin confused myself. Give me 5 to 10 mins

  2. #17
    Join Date
    Jan 2014
    Posts
    27
    Let me sort this step by step, so first I will create a temp table. One minute

  3. #18
    Join Date
    Dec 2013
    Posts
    63
    1. In PHPMyAdmin call "DROP TABLE temp IF EXISTS".

    2. Run your php script.

  4. #19
    Join Date
    Jan 2014
    Posts
    27
    there is no table called temp. and its giving me error with that command "IF EXISTS"

  5. #20
    Join Date
    Dec 2013
    Posts
    63
    Sorry, my mistake. It should be "DROP TABLE IF EXISTS temp".

  6. #21
    Join Date
    Jan 2014
    Posts
    27
    Ok, I realised that there is something wrong with the Create TEMP table code.I think I might solve it

  7. #22
    Join Date
    Dec 2013
    Posts
    63
    I've tested your code on my localhost and it works. Only change I made was adding ending bracket ')' just after 'NAMEOfTheDVD VARCHAR(30)'.

  8. #23
    Join Date
    Dec 2013
    Posts
    63
    I've tested your code on my localhost and it works. Only change I made was adding ending bracket ')' just after 'NAMEOfTheDVD VARCHAR(30)'.

  9. #24
    Join Date
    Jan 2014
    Posts
    27
    But I tried all that sir. It does not work. How is it working for you and not for me?

  10. #25
    Join Date
    Jan 2014
    Posts
    27
    ok I dont know if this will help but this is what I got when i tried to create my temporary table in phpmyadmin

    SQL query:

    CREATE TEMPORARY TABLE IF NOT EXISTS temp(

    'temp_id'
    )
    MySQL said: Documentation

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''temp_id')' at line 1

  11. #26
    Join Date
    Dec 2013
    Posts
    63
    Why did you do that???!!!

    It's not enough! You gave only the name of one field (temp_id) without its definition.

    Your code should be:
    Code:
    CREATE TEMPORARY TABLE IF NOT EXISTS temp (
        temp_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
        ArtistName VARCHAR(20),
        NAMEOfTheDVD VARCHAR(30)
    )

  12. #27
    Join Date
    Jan 2014
    Posts
    27
    OKKKKKKK UHHHH THIS IS WHAT I GOTT

    Your SQL query has been executed successfully (Query took 0.0123 sec)
    SQL query:
    CREATE TEMPORARY TABLE IF NOT EXISTS temp(
    temp_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    ArtistName VARCHAR( 20 ) ,
    NAMEOfTheDVD VARCHAR( 30 )
    )Engine=MyISAM

    But it has not created the table. Someone mentioned that maybe I dont have privilages to create a temporary table. Is that possible?

  13. #28
    Join Date
    Dec 2013
    Posts
    63
    Hmmm, did you make in phpmyadmin? I think it closes connections between switching its 'screen' so this table is quickly removed if you make something another in phpmyadmin. I think that you have to call several statements in one query box, one after another with ';' as a separator, but i'm not sure and i don't have phpmyadmin installed. but if it says 'Your SQL query has been executed successfully (Query took 0.0123 sec)' it meand that the code is correct, so put it into your php script and run all. but remember to change also 'echo $row_selecttemptable;' into 'echo $row_selecttemptable['ArtistName'];' in your script.

    EDT. If you don't have some privilleges phpmyadmin will tell you about it in proper moment

  14. #29
    Join Date
    Jan 2014
    Posts
    27
    Sir I just realised something.Umm..no matter what I call my temporary table name in PHP script. When I run it , I ma getting this message on the web browser 'Table 'db1104107.temp' doesn't exist'

  15. #30
    Join Date
    Jan 2014
    Posts
    27
    OH MY GOD!!! I GOT NEWS THAT TABLE EXISTSSSSSSSSSSSSSSSSSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    CREATE TEMPORARY TABLE IF NOT EXISTS temp(
    temp_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    ArtistName VARCHAR( 20 ) ,
    NAMEOfTheDVD VARCHAR( 30 )
    );# MySQL returned an empty result set (i.e. zero rows).
    INSERT INTO temp( temp_id, ArtistName, NAMEOfTheDVD )
    VALUES (
    '1', 'SHAWooSHANK', 'hhdh'
    );# Affected rows: 1



    WOOHOOOOOOOOOOOOO!!!


    ITS JUST MATTER OF RUNNING IT FROM PHP

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles