Jump to content

mysql, connecting to the table


ted_chou12

Recommended Posts

what do I have to include if i only want to connect to the table in mysql, no entry or updates, just simply connection to see if it works or not?
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
this is the previous (connect to mysql, and the database, but i wish i can connect to the table as well)
THanks, ted.
Link to comment
Share on other sites

you will always use

mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

(or similar - pconnect, mysqli etc etc). TEST is the name of the database NOT the table.

The localhost, admin and 1admin are your connection details host, username, password - these will more than likely change on a  per site basis.

thats it. That makes a connection.

After that you will query each table(s) for what ever info you need.
[code]<?php
$qry = "SELECT * FROM `users` WHERE `password`= '" . sha1($_POST['password'] . "'";
$qry = mysql_query($qry);

...

?>
[/code]

Hows that?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.