Sql Query - How do i run an SQL query

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Sql Query - How do i run an SQL query

nerdy monkey
I have been attempting to add mods to PHPbb forums for a while now but i have been unable to because i have no idea how to run a Mysql or SQL Query. if anyone could let me know how i would greatly appreciate it.

Reply

cse-icons
hi,
I did not exactly understand what u mean by executing sql query for phpbb mods.
From what I understand is u have a script which needs to be executed for the phpbb mod to work.
To do this login to cpanel and go to phpMyadmin.
Select the database on which u want to execute the query.
Select the SQL tab.
Type in or upload the file with the sql statements and click go.
All the sql statements in the file will execute one after the other.

For executing the query thru php
go to the cpanel and select mysql databases.
For the database that u require, there will be connection string available for perl,php and jdbc. U can use the php connection string for getting a connection in php and executing the sql query.

Cheers.

Reply

nerdy monkey
that is exactly what i wanted to know. thank you very much, that should be very useful laugh.gif

Reply

littleweseth
QUOTE(nerdy monkey @ Aug 23 2005, 04:26 AM)
I have been attempting to add mods to PHPbb forums for a while now but i have been unable to because i have no idea how to run a Mysql or SQL Query. if anyone could let me know how i would greatly appreciate it.
*



To run an SQL query, first you have to connect to your server thusly :
CODE
mysql_pconnect ( $ServerAddress, $mySQL_Username, $mySQL_Password );


Then you have to select a database, like so.
CODE
mysql_selectdb ( $DataBaseName );


Then you run a query like this :
CODE
mysql_query ($querystring );


Hope that helps.

 

 

 


Reply

pawitp
QUOTE(littleweseth)
To run an SQL query, first you have to connect to your server thusly :
CODE
mysql_pconnect ( $ServerAddress, $mySQL_Username, $mySQL_Password );


Then you have to select a database, like so.
CODE
mysql_selectdb ( $DataBaseName );


Then you run a query like this :
CODE
mysql_query ($querystring );


Hope that helps.

I don't think that's the case. PHPBB use a database layer to communicate with the database instead of using the database directly. So it is compatible with multiple Database so I think you should use the Database layer. I don't remember but you can study code in the PHPBB directory

Reply

littleweseth
I was just looking through the phpBB code, and, indeed, it does have a database abstraction layer. That's because phpBB doesn't know where it will be running - except that it will be on some PHP machine, with some database it can talk to using SQL. However, since we - the end-user - know that it will be running on mySQL, we don't need to use abstraction because we know that we're only writing the hack to run in one place. Of course, if you do move to a non-mySQL database, you're royally shafted.

Oh, and i screwed up : it's mysql_select_db().

Reply

alicabektas
picke the of is Mambo solutions for Website

Mambo solutions (PHP and MySQL) !

when work web site, you can update files and more plenty ...

Update files : unsure.gif

- Mambo modules
- Mambo componentes
- Mambo mambots

happily biggrin.gif biggrin.gif biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : sql query sql query

  1. Sql Query - Mistake? (19)
  2. Simple Mysql Query Limiting - (9)
    Simple MySQL Query Limiting CODE <?php // If mypage?limit=blah is not defined returs 5
    if ( $_GET['limit'] == NULL ) {     $limit = 5; } // Else else {
        $limit = $_GET['limit']; } $query = mysql_query("SELECT
    * FROM members LIMIT '$limit'") or die(mysql_error()); while
    ($sql = mysql_fetch_array ($query) ) {     echo
    $sql['mem_name'] . '<br>'; } ?> Have fun.....
  3. Mysql Query - (2)
    theres a bug somewhere in this query and i can't seem to find it. does anyone else see it?
    CODE $query = "insert into templates
    (tuid,tname,tdescription,template,archivedefault) values (1,'Sample Archive
    Template','A sample archive template that only shows the name of the article with a link to
    the default article viewer.','<a
    href='viewarticle1.php?aid=[id]'>[articletitle]</a>',FALSE&#
    41;"; ...
  4. Using And?or In A Mysql Query - (2)
    hi everyone,


    I have been trying to get a script to come up with the total number of comments a news item has
    under it
    news ...
  5. Error Importing Sql Query Via Php - Works in PHPmyAdmin (6)
    CODE     function sql()     {         $fp =
    fopen("sql.sql","r");         $sql =
    fread($fp,filesize("sql.sql"));         fclose($fp);
            return $sql;     } Thats $this->sql and here is the other source CODE
    function insert_sql()     {     if($_GET['insert'])  {
            $template = new template;         $db = new db;
            $db->connect();         $query = $this->sql();       ...
  6. Query Not Running When Submitting A Form - (3)
    Im having trouble getting my PHP to work. Basically i have a form with a button linking to a php
    file. When i click submit it calls this file and is suppost to add the data to a database. Im using
    a my sql databse and it connects fine. Unfortunately when i click submit all i get is the
    "Inspection did not add". From this i know i have made a connection with the database and im
    absolutely 100% sure that all field names are correct on the forms and database. Any ideas? Heres
    the script.... PHP Code: CODE <html> <head> <meta http-equiv="C...
  7. Problem With Mysql Query - (1)
    I know this isn't the SQL forum but MySQL is used in PHP. I get an error Query: SELECT
    COUNT(users.*), COUNT(guests.*) FROM users INNER JOIN guests ON users.code != '' AND
    users.last_active >= 1106971028 AND guests.time >= 1106971028 AND users.last_ip != guests.ip
    Error#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 '*), COUNT(guests.*) FROM users INNER JOIN
    guests ON users.code...



Looking for sql, query, run, sql, query

Searching Video's for sql, query, run, sql, query
advertisement



Sql Query - How do i run an SQL query



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE