473,379 Members | 1,263 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,379 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 7258
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.