/    Sign up×
Community /Pin to ProfileBookmark

Does anyone know of a site that has a page that allow people to test MySQL with php.
I want to be able to learn how to use MySQL with php and with my current server I can’t test MySQL.

to post a comment
PHP

17 Comments(s)

Copy linkTweet thisAlerts:
@SheldonFeb 27.2006 — Do you have php and mysql installed then test it on your own server, set up a dummy sql database and your away with less fuss than trying to find some one else that will let you mess around and destroy there server.
Copy linkTweet thisAlerts:
@NogDogFeb 27.2006 — I'd recommend installing PHP, MySQL, and Apache on your PC. Then you can experiment and test locally instead of on the web. I'd recommend XAMPP as a simple and convenient way to do this: http://www.apachefriends.org/en/xampp.html
Copy linkTweet thisAlerts:
@Wisest_GuyauthorFeb 28.2006 — Well I don't need to use database[I][B]s[/B][/I] I just need to test using a single database.

Or can someone tell me what print_r($result); would look like with

$result = mysql_query(<various queries>);
Copy linkTweet thisAlerts:
@bokehFeb 28.2006 — can someone tell me what print_r($result); would look like with$result = mysql_query(<various queries>);[/QUOTE]It would print something like: [CODE]Resource id #1[/CODE]
Copy linkTweet thisAlerts:
@Wisest_GuyauthorMar 01.2006 — What does $result look like with the query

"SELECT * FROM Some_Table_Name"
Copy linkTweet thisAlerts:
@SheldonMar 01.2006 — Well it dependson what you havestoredin the whole dastabase, because thats what your selecting.

You would be better to use a a while or foreach after your function

for example.
[code=php]

<?php
echo("<ul>");

$s = "SELECT names FROM users ORDER BY names ASC";
$q = mysql_result($s);

while($r = mysql_fetch_assoc($q)){

echo("<li>".$r['names']."</li>");

}

echo("</ul>");

?>
[/code]


will output an unordered list of all the names in your database.


If thats not what you want [b]be more specific!! less argo[/b]
Copy linkTweet thisAlerts:
@Wisest_GuyauthorMar 01.2006 — What does print_r($q); look like?
Copy linkTweet thisAlerts:
@SheldonMar 01.2006 — try it and see, you need to set up your own sql db. if you dont have sql, then try at http://www.freemysql.com


We arnt going to do all your work for you.
Copy linkTweet thisAlerts:
@NogDogMar 01.2006 — The return value of a mysql_query() function is a resource ID, which means nothing to anyone except to PHP (it's sort of like a pointer). You must use a function like mysql_fetch_assoc() to retrieve actual data from the specified resource ID.
Copy linkTweet thisAlerts:
@Wisest_GuyauthorMar 01.2006 — I can't install or use mysql right now.

if I have a table named ID2Name like this

ID Name

0 Bob

1 Fred

what will print_r(mysql_query("SELECT * FROM ID2Name")); look like?
Copy linkTweet thisAlerts:
@Wisest_GuyauthorMar 01.2006 — Or how can I convert $result to an array thats something like

Array("ID" => Array(0,1),"Name" = > Array("Bob","Fred"))
Copy linkTweet thisAlerts:
@NogDogMar 01.2006 — it will print either "0" (false) if it fails, or something like "Resource ID #n" where "n" in some integer. As I said, it's just a pointer to the mysql result set and is otherwise meaningless. You must use one of the mysql_fetch functions to actually get meaningful data.
Copy linkTweet thisAlerts:
@Wisest_GuyauthorMar 02.2006 — Then how can I convert $result to an array thats something like

Array("ID" => Array(0,1),"Name" => Array("Bob","Fred"))
Copy linkTweet thisAlerts:
@NogDogMar 02.2006 — Start by reading the manual: http://www.php.net/manual/en/function.mysql-fetch-assoc.php

Take a look at the "PHP class for MySQL" in my sig, below - particularly the select() method of the DB class.
Copy linkTweet thisAlerts:
@Wisest_GuyauthorMar 02.2006 — I have.

Is there any built in function that needs only to be used once to get an array

or do I need to use a loop?
Copy linkTweet thisAlerts:
@bokehMar 02.2006 — Please, read the [URL=http://www.php.net/mysql]official documentation[/URL] on accessing MySQL from PHP scripts.
Copy linkTweet thisAlerts:
@NogDogMar 02.2006 — ...Is there any built in function that needs only to be used once to get an array...?[/QUOTE]
If I knew of one, I wouldn't have written my own function to do it.
×

Success!

Help @Wisest_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...