Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Mysql Error
demonlord
post Jun 7 2008, 04:05 PM
Post #1


Member [Level 3]
******

Group: [HOSTED]
Posts: 92
Joined: 1-January 08
Member No.: 55,554



ok i need some more help from the wonderful coders here at Trap. I'm almost done with my CMS script, but i'm having a problem with the installer.php file, when it trys to inseret the user data into the database i keep getting the following error:

CODE
mySQL Error: 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 ';INSERT INTO `members` (`id`, `name`, `username`, `password`, `email`, `title`) ' at line 1


the code that is being excuted by the php file is this:

CODE
$SQL = get_sql();
    
     foreach( $SQL as $q )
     {
              
        if ( preg_match("/CREATE TABLE (\S+) \(/", $q, $match) )
        {
            if ($match[1])
            {
                $the_query = "DROP TABLE if exists ".$match[1];
                
                if (! mysql_query($the_query, $connect_id) )
                {
                    install_error("mySQL Error: ".mysql_error());
                }
            }
        }
        
                  
        if ( ! mysql_query($q, $connect_id) )
        {
            install_error("mySQL Error: ".mysql_error()."<br /><b>Query:</b>".$q);
        }
    }
    
    // Insert the admin...
    
    $passy = $VARS['adminpassword'];
    $username = $VARS['username'];
    $email2 = $VARS['email'];
    $adminname2 = $VARS['adminname'];
    $query .= "INSERT INTO `members` (`id`, `name`, `username`, `password`, `email`, `title`) VALUES ('1', '$adminname2', '$username', '$passy', '$email2', 'Administrator');";
    $query .= "INSERT INTO `members` (`id`, `name`, `username`, `password`, `email`, `title`) VALUES ('2', 'John Smith', 'username', 'password', 'email@domain.net', 'Tech Support');";

            
    if ( ! mysql_query($query, $connect_id) )
    {
        install_error("mySQL Error: ".mysql_error());
        
    }

for some reason i cant see the error in there, knowing me it's probley something simple and easy to fix and i'm just over looking it. so if i could get some help that would be great.

Thanks
Go to the top of the page
 
+Quote Post
Erdemir
post Jun 7 2008, 04:50 PM
Post #2


Super Member
*********

Group: [HOSTED]
Posts: 217
Joined: 12-May 08
From: Istanbul, Turkey
Member No.: 62,045



I didn't use CMS before but as my php and sql knowledge,

Can you write the structure of the table members. Maybe the fields `id`, `name`, `username`, `password`, `email`, `title` are not exist.

And also can you write the line 1 from the beginning to the character ';' .

Then maybe I can tell a definite solution.
Go to the top of the page
 
+Quote Post
jlhaslip
post Jun 8 2008, 02:35 AM
Post #3


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 4,081
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol



run the queries individually using phpmyadmin to see if they work outside of the script.
I am suspicious about the single quotes and semi-colons at the end of the Insert lines???
Go to the top of the page
 
+Quote Post
demonlord
post Jun 8 2008, 06:55 PM
Post #4


Member [Level 3]
******

Group: [HOSTED]
Posts: 92
Joined: 1-January 08
Member No.: 55,554



i did that to start out with, what i did was i went in to my phpmyadmin add the table and the fields manualy then i add the user william with all the right info and when it added it it showed me a box that had the queire in it and i clicked on get php code and i copyed and paseted that into my script. so i dont know what was wrong with it, but i was able to fix it by moving the second part:

CODE
INSERT INTO `members` (`id`, `name`, `username`, `password`, `email`, `title`) VALUES ('2', 'John Smith', 'username', 'password', 'email@domain.net', 'Tech Support');


into the get_sql fuction in the script and it worked fine. so i'm not sure why it would not take it the way i had it. but oh well at least i got it fix.

Thanks
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Problem On Mysql "order By"(5)
  2. Php News Script(19)
  3. Trouble With Emailer.php(6)
  4. Increment A Mysql Column(7)
  5. Parse: Error Unexpected T_lnumber(4)
  6. Can You Add Images Into A Mysql Database?(20)
  7. Subquery In Mysql(5)
  8. Creating Profiles In Php/mysql ?(7)
  9. Php Search Engine Script For Mysql Database(11)
  10. Some Mysql Basics(4)
  11. Php And Mysql Applications(3)
  12. Getting Php 5 To Work With Mysql(0)
  13. Problem With A Mysql Join(2)
  14. The Artists Tutorials :mysql Basic Commands(0)
  15. T_string Error Please Assist(5)
  1. [mysql]get Id Of Loged In User?(7)
  2. [mysql/php]need Som Basic Help(13)
  3. [php/mysql]id Trouble [resolved](3)
  4. Mysql Won't Update(4)
  5. Php + Mysql Question!(4)
  6. Php Objects: Catchable Fatal Error(4)
  7. Tools Needed!(9)
  8. Best Sites For Learning Php-mysql(4)
  9. Php And Mysql Programming(2)
  10. Best Php And Mysql Editor For Noobs(6)
  11. Html Form!(4)
  12. Create Table - Mysql Code - Help(1)
  13. Linux/ Apache /mod_rewrite Issue(4)


 



- Lo-Fi Version Time is now: 12th October 2008 - 06:15 PM