|
-
Jan 19th, 2004, 05:36 AM
#1
Thread Starter
Hyperactive Member
Searching mySQL database!!
Last edited by raladin; Mar 29th, 2014 at 10:44 PM.
-
Jan 19th, 2004, 06:13 AM
#2
Hi raladin.
Do you have an actual question? You've got to learn PHP and MySQL of course. Beyond that, we cannot help you yet. We're here to solve problems, not write programs.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 19th, 2004, 07:38 AM
#3
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:43 PM.
-
Jan 19th, 2004, 08:00 AM
#4
Re: Searching mySQL database!!
Originally posted by raladin
Hi all..
First of all I want to introduce my self because I'm sure you are saying "Who is this guy!!! a very stupid guy " so :
I'm 14 years old.. in the 9th grade (At school).. you know I don't have the enough time to learn much about PC languages... so I'm now prepairing to get CompTIA A+ and I know of course HTML and PhotoShop..... Also I have many certificates from : the Associated Board of the Royal Schools of Music - Lodon in playing Classical Piano.. and I'm prepairing for the Dip. the next year..
And I will receive a FULL ScholarShip from Carnegie Mellon as they said me and my brother..
I don't play the piano, but I can use winamp really well. I have no certificates for it though. However, I can easily see how your certifications with the pianos are going to help you with your project. 
I made 90% of my new project (E-Learning System) and I want now something in PHP (I'm new to PHP).. I want to make a PHP page for the admin to activate users accounts.. so a PHP page with a TextBox (UserName) with an "Activate" button.. the admin enters the user name for any user.. and then press the "Activate".. the PHP page will search the database for that username.. and when it find its row there it will change a value in the database (In that row).. the value that will be changed is under the field "Activation" from "Not Activated" to "Activated".. so the user now is activated..
Hope you got my meaning.. and sorry for my bad English
Example code off google:
PHP Code:
function dbConnect()
{
//define the database connection information
$dbHost = "localhost";
$dbUser = "username";
$dbPass = "password";
$dbName = "nameofdatabase";
//connect to the mysql server
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
//return success or failure of connection
if(!$link)
{
//report error
echo "Could not connect to server";
exit;
}
//select the database
if(!@mysql_select_db($dbName))
{
//report error
echo "Could not select database";
exit;
}
}
Once connected (using similar-to-above code), you can query it:
PHP Code:
$result = mysql_query("SELECT * FROM myusers WHERE username='" + $storedvar + "'",$db);
//$storedvar retrieved from the previous page
if mysql_result($result,0,"activated") == "0"
{
$result2= mysql_query("UPDATE myusers SET activated='1' WHERE username = '" + $storedvar + "'", $db)
}
This is just a rough example. GO through this link here for a good DB tutorial:
http://hotwired.lycos.com/webmonkey/...tw=programming
Notice : I attached my CV and my brothers' CV to see them
Thank you. I'll forward these to Newt Gingrich ASAP. He'll know what to do with you two.
-
Jan 19th, 2004, 08:40 AM
#5
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:47 PM.
-
Jan 19th, 2004, 09:19 AM
#6
Stuck in the 80s
I think you googled bad code. Much easier to do:
Code:
function dbConnect() {
//define the database connection information
$dbHost = "localhost";
$dbUser = "username";
$dbPass = "password";
$dbName = "nameofdatabase";
//connect to the mysql server
$link = @mysql_connect($dbHost, $dbUser, $dbPass) or die('Could not connect to server.');
mysql_select_db($dbName, $link) or die('Could not select database.');
}
Maybe that's just my opinion, though.
-
Jan 19th, 2004, 09:26 AM
#7
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:47 PM.
-
Jan 19th, 2004, 11:00 AM
#8
Originally posted by The Hobo
I think you googled bad code.
I googled for "how would hobo connect to mysql?"
-
Jan 19th, 2004, 11:09 AM
#9
Must I store the variable MD5.. or I can import it then convert it to MD5 then echo it?
What variable
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 19th, 2004, 11:17 AM
#10
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:47 PM.
-
Jan 19th, 2004, 11:19 AM
#11
Stuck in the 80s
Originally posted by raladin
Thanks The Hobo for your reply.. it is the same..
No, it's not the same. Mine is a few lines shorter. Plenty of characters shorter. Shorter means less file size. And in a big project, that matters to some.
Originally posted by raladin
but mendhak gave me a code also to insert the value to the database..
Yes, I know this. Thanks.
-
Jan 19th, 2004, 11:20 AM
#12
Stuck in the 80s
Originally posted by mendhak
I googled for "how would hobo connect to mysql?"
Well, google lies. It's all lies!
-
Jan 19th, 2004, 11:25 AM
#13
In case you guys don't know, raladin here is trying to make a super-secure app that would transfer the user's hard drive serial number to his website.
It's 4 lines of code that retrieves the serial number, and 2000 lines of code for securing it.
Now he's at the PHP part.
And he plays the piano as well.
-
Jan 19th, 2004, 11:28 AM
#14
Stuck in the 80s
Thanks for the wrap up. Sounds like fun.
-
Jan 19th, 2004, 11:35 AM
#15
I think it'd probably be alot easier to control the database from the VB program, instead of relying on some PHP script.. I guess it would depend on how well he knows VB though.
-
Jan 19th, 2004, 11:44 AM
#16
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:48 PM.
-
Jan 19th, 2004, 11:49 AM
#17
Stuck in the 80s
Originally posted by raladin
Waiting your help..
On what? You didn't ask a question...
-
Jan 19th, 2004, 11:54 AM
#18
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:48 PM.
-
Jan 19th, 2004, 11:57 AM
#19
Stuck in the 80s
The same way you're comparing user names in the code you provided.
-
Jan 19th, 2004, 12:07 PM
#20
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:48 PM.
-
Jan 19th, 2004, 12:14 PM
#21
Thread Starter
Hyperactive Member
Last edited by raladin; Mar 29th, 2014 at 10:48 PM.
-
Jan 19th, 2004, 12:18 PM
#22
Stuck in the 80s
I personally think the easiest thing to do is to use mysql_fetch_array rather than mysql_fetch_row.
Code:
$rows = mysql_query("SELECT * FROM tblName") or die(error_thing_here);
$row = mysql_fetch_array($row) or die(error_thing_here);
// Now you can access by field name:
if ($password = $row['password_field_name']) {
// Do something
}
That way you don't have to worry about whether it's the 1st, 2nd, or 3rd field, you can just access it by what you named it.
Much easier, in my opinion.
But yes, you're on the right track.
-
Jan 19th, 2004, 01:30 PM
#23
Originally posted by kows
I think it'd probably be alot easier to control the database from the VB program, instead of relying on some PHP script.. I guess it would depend on how well he knows VB though.
Control a MySQL database from VB?
Errr...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 19th, 2004, 02:07 PM
#24
Stuck in the 80s
Originally posted by CornedBee
Control a MySQL database from VB?
Errr...
Why Errr?
It can be done through VB, although most of the hosts I've had in my life don't allow outside connections to the database.
-
Jan 19th, 2004, 02:44 PM
#25
why err? it can be done.. I'm making a project right now that does it.. Maybe I should have used "interact with" instead of "control"?
Most web hosts don't allow remote connections, but some do.. most good ones I've found allow it.
-
Jan 19th, 2004, 02:51 PM
#26
Stuck in the 80s
I'm sure I wouldn't be too happy if anyone could connect to my database and start trying to log in.
I should mention that my host allows you to add IP addresses to allow certain remote machines to connect. In that case, that's a good method, as you can control who connects to your database.
-
Jan 19th, 2004, 06:02 PM
#27
But unsuited for the situation.
How do you deal with a MySQL database from VB? MyODBC?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 19th, 2004, 06:22 PM
#28
Unsuitable for the situation? The guy is using a VB application to basically update the database and check if some user information is correct, and he's just using PHP as a middle man. I suggested it just so that he would cut out PHP and leave it as plain VB and MySQL.
By the way, yeah, MyODBC is used for VB/MySQL interaction.
-
Jan 19th, 2004, 06:32 PM
#29
I was referring to the "accept specific IPs". Since every user of his app needs to connect there, that's quite a lot of IPs to activate, aside from the impossibility of finding out which.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 19th, 2004, 06:37 PM
#30
Stuck in the 80s
Plus, dialup users have changing IPs, so each time they connected to the internet, they'd have to give you their IP to allow the connection.
Unless the server allowed any computer to connect. And that's not cool, if you ask me.
-
Jan 19th, 2004, 06:40 PM
#31
As long as the passwords a secure and there's always the latest security updates...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 19th, 2004, 06:44 PM
#32
Stuck in the 80s
Originally posted by CornedBee
As long as the passwords a secure and there's always the latest security updates...
Whatever floats your boat.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|