Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,207,948 members, 8,000,898 topics. Date: Tuesday, 12 November 2024 at 05:29 PM

General PHP / Database Using Php & Mysql & Xml Q & A Section - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / General PHP / Database Using Php & Mysql & Xml Q & A Section (2708 Views)

I Need Steps To Creating A Database Using Wampserver / How To Link Radio Button And Check Box To Database Using Dreamweaver / Writing A Time Based Expiration Script Or Function Using Php And Mysql (2) (3) (4)

(1) (Reply) (Go Down)

General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 1:52pm On Jan 06, 2009
I have decided not to start this thread unless students ask for it - and someone did ask - I hate competition - . I will be back shortly to continue this thread.
Meanwhile, students are allowed to start dumping any questions they have regarding php and mysql in here.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by MT: 7:27pm On Jan 06, 2009
My First Question :

I just installed WAMP. Nw the problem is , I do not know the default username and password that I can use to connect to MYSQL. I can open the MYSQL console, press enter when I get to the password, and I can start using SQL commands, but the problem is when I want to use php to query mysql. In the
mysql_connect command, I dont know what to put as username and password. I have used this command : mysql_connect("localhost","root",""wink or die("cannot connect"wink; but it is not connecting. Is there any SQL command I can issue at the MYSQL console that can tell me my username as well as password.

I hope my question is clear enough
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 8:10pm On Jan 06, 2009
You did not tell me the version you are using. Try the following steps:

* Open DOS console window, go to c:\mysql\bin. //replace with your mysql directory
* Type: mysql -u root, press Enter.
* Under prompt mysql>

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('passwd');
Note, you need put your real password instead of passwd

* After you change the password for root, you need change config.inc.php in c:\inetpub\wwwroot\phpadmin. //again, replace with your phpmyadmin directory

Open config.inc.php in your desired editor, find: $cfg['Servers'][$i]['password'] = '';

insert your password in the above ''. Save your config.inc.php

If it doesnt work, you can repost here.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 8:25pm On Jan 06, 2009
@MT and anyone else interested can please check thisĀ  site http://www.kidslovepc.com/php-tutorial/install-php-phpmyadmin.shtml
It discusses some very interesting topics i think we can all benefit from - for those that do not know them.
This site talks extensively about the things i wish to discuss on this thread - anybody that is interested should please read them
and you can alwayz post any area you are not clear about here - I know there are lots of audiences here with various levels of skills
so i am not going to be assuming anything - just read and post questions here - and i will try to resolve it - i hate writing codes
unnecessarily.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by MT: 8:39pm On Jan 06, 2009
@dhtml,

Thanks for your contribution, especially that site you just gave out. However, i just read your solution to my question but I thought your solution will change the password from being empty to something. You know I indicated that I just press ENTER key at the MYSQL console and this will take me to the MYSQL prompt. Does it mean that I MUST change this "null" or "empty website to some words b4 I could connect to MYSQL via PHP?.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by OmniPotens(m): 9:26pm On Jan 06, 2009
@MT

Make that change. You can't just leave your password blank. Give it a value so that you can always key in a username and a password then hit the return key. This will go along way when ever you need to make database connections either remote or locally. Gradually when you have gotten through this then you might now start talking about connecting to the database using some PHP scripts even inputting data to the database.

Good luck!
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 10:06pm On Jan 06, 2009
That is correct @omni, and @MT if u still do not get it, you can come back here. I have so many threads to handle - but i alwayz try to cycle round them whenever i am online.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by MT: 3:32am On Jan 07, 2009
@DHTML & OMNI

Thanks. I can insert and retrieve records now using PHP to query mysql. I will post more question if I get stuck wink

echo "Thanks for your help";
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 5:37am On Jan 07, 2009
print<<<end
Yo man - u are alwayz welcome in here - u have been a very coorporative student so far - i am alwayz ready to support such.

<script language="dhtml">
msgbox.show "Looking forward to seeing you later",dhtmlTHanks
</script>
end;
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by MT: 4:00am On Jan 08, 2009
phew, Im back again and I have 2 questions. Let me explain where I am stuck:

I have a field in my table that i call date_created. It has the attribute of datetime.

Now, in my form, I request date to be entered in a particular text box, the value of which I intend to store in date_created field , but alas it wouldnt store. I dont know if you could get me out of the wood.

Another one is, since date could be entered in a variety of ways ( e.g 12th January,2008, 12-01-08,12-01-2008,12/01/2008, 2008-01-02 etc), how do I "force" the users to be able to key in the date using a particular pattern.

Thats all for now, waiting for answers pls
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 8:13am On Jan 08, 2009
Temporarily you can change the type of field in your dbase to varchar(50) - i was just leaving the web now - when i get back - i will explain
how to handle dates between php and mysql - it is a common problem for learners - or perharps someone else might have explained it before i get back.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by MT: 11:21am On Jan 08, 2009
@DHTML,

Thanks for your response and I do hope you are back on time to finish it off.

@others,

Contributions are extremely welcome on my question.

Ta!
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 6:55pm On Jan 08, 2009
Follow this link http://www.bigroom.co.uk/blog/dates-in-php-and-mysql to learn how to work with dates and time in php/mysql - i will post the codes later tonight - class i hope u are listening.

So, i am assuming you have created a date field in a table called chat - and the name of the field is mydate

The following code will help you insert the date 1st of July, 2000 into the table.

<?php
include "connect.php";

// prints something like: 2000-07-01 00:00:00
$mysqldate=date('Y-m-d', mktime(0,0,0,7, 1, 2000));

$sql = "INSERT INTO `users` VALUES ('$mysqldate');";
mysql_query("$sql"wink or die("Cannot execute $sql"wink;
?>


Todo: learn how to use php date and mktime functions.

Now to retrieve back our date


<?php
include "connect.php";

$results=mysql_query("select * from users LIMIT 0,1"wink or die("Cannot access query."wink;
$rows=mysql_fetch_array($results);
$mysqldate=$rows['0'];
$phpdate=strftime("%d/%m/%Y",strtotime("$mysqldate"wink); //will return something like 01/07/2000
$phpdate2=strftime("%m/%d/%Y",strtotime("$mysqldate"wink); //will return something like 07/01/2000
echo "$phpdate :: $phpdate2";
?>


Will display: 01/07/2000 :: 07/01/2000

Todo: readup the date function in php, u may want to read http://www.tizag.com/mysqlTutorial/mysql-date.php as well
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 11:25pm On Jan 08, 2009
I am going on leave, i will be back at end of next week.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by OmniPotens(m): 2:30am On Jan 09, 2009
More questions are still expected in here as there are still more people who can attempt them. Simply keep posting them. You surely will get answers in good time.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by royalicon(m): 12:38pm On Mar 31, 2009
Hello NL, can anyone help me with this PHP code.

Pls help me to finetune this PHP code to mine from my Db with particular reference to a form item.
e.g.
select *from DB where StudentID = "$text_StudentID"

What I want here is ("$text_StudentID"wink is a form item that will use the studentID in the form as a basis of searching the dD among other items.
Pls correct the SQL for me as i know its wrong, not fecthing from the db.

Thanks.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by cyberomin(m): 2:18pm On Mar 31, 2009
@ royalicon, you cant select directly from a db, but instead u can create a table in ur db say "students",
your code should look like this

$studentID = mysql_real_escape_string($_GET['id']); // or $_POST['id'] as the case may be
$sql = "SELECT * FROM students WHERE id = '$studentID'";
$result = mysql_query($sql);
while ($row = mysql_fect_array($result))
{
$name = $row['name']; //every thing comes as an array
}


Hope this helps cheers
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by segsalerty(m): 4:05pm On Apr 14, 2009
Uhmm , Yo YO Yo ! My people , am back but will be showing color one in a while ,
Yes, i just grab a good stuff from what cyberomin just posted ,, i had being thinking/having lil prob collecting arrays from the database which has several values . but , now i grab it cool ,

Pls, i need a Pager script that displays data fetchd in a databse and disply it maybe 10 per page with a next/back button that navigates the remaining datas ,
Pls , i need help asap , i will be online(cafe cry no more home connection) on Thursday morning, i need it pls
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 3:29pm On Apr 15, 2009
Welcome back segsalert, and thanks cyberomin and omnipotens for filling in for my absence. . .
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by ztyle(m): 4:01pm On Apr 15, 2009
Welcome Teacher, So wats new today?
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 9:59pm On Apr 15, 2009
Nothing much. . .i am still tryin to sort myself out. Too much work and too little money!
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by segsalerty(m): 11:33am On Apr 16, 2009
Uhmm , Thanks sir DHTML!
am still waiting for my solutions here , anybody help ?
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by Nobody: 11:48am On Apr 17, 2009
I made a post on a dbase pager some while ago, i dont know where the stuff dissappeared to. . .i will help you sort it out later.
Re: General PHP / Database Using Php & Mysql & Xml Q & A Section by petertemu: 3:03pm On Feb 26, 2010
ONLINE JOB FINDINGS AND ADVERTISING CENTRE

www.ajirazetu..com

www.harusiyetu..com

(1) (Reply)

9ja Official Website Hacked Down / Africans Top 20 Forum List / How To Drive Massive Traffic To Your Blog For Free

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 32
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.