473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

MySQL use with JavaScript, client side

Hello all !

I am a bluebit in JavaScript.
I would like to write a little program to read data in a MySQL database.
What do I need ?
Is there a specific "JavaScript Include" to make this work ?
Do you have examples or site links to help me ?

Thanks in advance,

Pippin999
Jul 20 '05 #1
4 7259
SuperPippin wrote:
Hello all !

I am a bluebit in JavaScript.
I would like to write a little program to read data in a MySQL database.
What do I need ?
Is there a specific "JavaScript Include" to make this work ?
Do you have examples or site links to help me ?

Thanks in advance,

Pippin999


You can't do that clientside (at least not in plain javascript, you'd have
to use applets/activeX stuff).

--
mvg,
Christophe Vanfleteren
Jul 20 '05 #2
SuperPippin wrote:
Hello all !

I am a bluebit in JavaScript.
I would like to write a little program to read data in a MySQL database.
What do I need ?
Is there a specific "JavaScript Include" to make this work ?
Do you have examples or site links to help me ?

Thanks in advance,

Pippin999

To my knowledge you cannot directly access a MySQL database with
Javascript. What I do is use PHP to pass the database work to the
javascript.

Jul 20 '05 #3

"chotchki" <ch******@mail.usf.edu> schreef in bericht
news:bm**********@news1.usf.edu...
SuperPippin wrote:
Hello all !

I am a bluebit in JavaScript.
I would like to write a little program to read data in a MySQL database.
What do I need ?
Is there a specific "JavaScript Include" to make this work ?
Do you have examples or site links to help me ?

Thanks in advance,

Pippin999

To my knowledge you cannot directly access a MySQL database with
Javascript. What I do is use PHP to pass the database work to the
javascript.


Why not using only PHP....
Jul 20 '05 #4
Ang Talunin wrote:
"chotchki" <ch******@mail.usf.edu> schreef in bericht
news:bm**********@news1.usf.edu...
SuperPippin wrote:
Hello all !

I am a bluebit in JavaScript.
I would like to write a little program to read data in a MySQL database.
What do I need ?
Is there a specific "JavaScript Include" to make this work ?
Do you have examples or site links to help me ?

Thanks in advance,

Pippin999


To my knowledge you cannot directly access a MySQL database with
Javascript. What I do is use PHP to pass the database work to the
javascript.

Why not using only PHP....

You do have a point, here is a sample piece of code Talunin to do it
just in php. Its a stripped down login form try changing the "some*" to
their proper values and trying it out.
Check out www.php.net for more info.

<html>
<head>
<title>Login Page</title>
</head>
<body>
<?php
trim($usernm);
trim($pass);

$db = mysql_connect("localhost", "someuser", "somepassword");

if (!$db)
{
echo "Error: Could not connect to database. Too bad.";
exit;
}

if (!mysql_select_db("somedatabase"))
{
echo "Error: Could not select database. Too bad.";
}
$sql = "select * from sometable where username='".$usernm."'
AND passwd='".$pass."';";
if ($result = mysql_query($sql, $db))
{
if (mysql_fetch_row ( $result))
{
setcookie ("LoginCookie", $usernm);
echo "Authenticated";
}
else
{
echo "<form method=\"post\" target=\"_self\">";
echo " <input type=\"text\" name=\"usernm\" />";
echo " Username";
echo " <input type=\"password\" name=\"pass\" />";
echo " Password";
echo " <input type=\"submit\" value=\"Login\"
name=\"SubmitButton\" />";
echo "</form>";
}
}
?>

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
3
by: Terry A. Haimann | last post by:
I realize this has been probably covered. But I want to pull data from one of several mysql tables, depending on what choice is made from a select box. Is javascript a good choice? I have poked...
9
by: alonzo | last post by:
I am working on a piece of javaScript code and using MIE 6.0. I have and error and I would like to use a debugger to locate the error. Is there a debugger for MIE? How do I turn the debugger on...
3
by: Liza | last post by:
dear all, does a client side script always need a server side script in order to function? how can i get my javascript application to send the details of a user filled form to me without...
2
by: RootShell | last post by:
Hello First of all i know that PHP is a server side, and JavaScript is a Client side programming language, but i need to know if there is any way i can add the variable "countDownInterval" from...
1
by: mike | last post by:
I'm fairly green with javascript, and have been looking everywhere for an example of how to load data from a mysql db into javascript arrays. For a little background on what I'm trying to do, any...
3
by: Mosher | last post by:
Hi all, I was wondering if there was any way that I can have a webpage with a text field that acts as a search box and when someone types even one character (letter or number) into the text field,...
7
by: Ivan Marsh | last post by:
Hey Folks, I'm having a heck of a time wrapping mind around AJAX. Anyone know of a simple, straight-forward example for pulling a simple query from mysql with PHP using AJAX? As I...
1
by: bcochofel | last post by:
Hi, I'm using Perl CGI and HTML::Template to generate the following XML: ---------------------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1"?>...
4
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I think I'm done for now,... Is it possible to insert recordset data in a javascript, for instance I have a javascript...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.