hi all
i am new to php and i am using wampserver to execute programs of php
I want to use mysql to retrieve data from a php program
but i am unable to use php from wamp
can anyone help me please

when i am trying to open mysql console from the wampserver icon i am getting a console that prompts for password but i didnt set any password while installing wamp
And i tried to give the password and i got the following output in the console
please help me in solving my problem
thanks in advance

this is the console output

IIRC the default password is blank (no password), so just hit enter.

:-O oh cool
thanks
its working...
thanks a lot
:)

hi

am getting an error in creating a table using mysql...
can anyone help me please
thanks in advance

You need to create and select a database first.

Once you have wamp server up and running, go to this URL "localhost/phpmyadmin" then Create a Database. Then inside the Database you created, You can create as many tables as you want.

if you still have any problems, just post them and we will try helping you.

I hope this helps you a bit :)

thanks for the info
but how can we create it using MYSQL console?

thanks all

hi can anyone help me please..

this is the code i am trying to implement..
but its giving an warning

<?php
  
  $con=mysql_connect("localhost","root","") or die("well please check ");
  if(mysql_query("create DATABASE hello"))
   {
       echo  "database created successfully";
   }
   mysql_select_db("hello");
   $empl="create table empl 
         (
           ename varchar(22) ,
           eno varchar(4), 
            salary int(5)  
             
           
              
          )";
      $res=mysql_query($empl) or die(mysql_error());  
      echo "databbase of emp is succesfully created thanks for creating";



     $sql="insert into emp1 values('abc','1c1',2004)";
      if(mysql_query("$sql"))
       {
          die("error ".mysql_error());
        }
      echo "1 record added";
     $ret=mysql_query("select * from emp1");
     while($rows=mysql_fetch_array($ret))
    {
      echo  $rows['ename']. "   ".$rows['eno'];      
     echo "<br>";
    }
      mysql_close($con);
 ?>

what's the problem with this code??
i am getting an warning as below :
" databbase of emp is succesfully created thanks for creating1 record added
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\myfiles\dbex.php on line 30"

thanks in advance..

select * from emp1, make sure that table name is correct, emp with 1 or l ?

thanks for the reply
i used the wrong table name
but now i am facing another problem with the code

<?php
  
  $con=mysql_connect("localhost","root","") or die("well please check ");
  if(mysql_query("create DATABASE hello"))
   {
       echo  "database created successfully";
   }
   mysql_select_db("hello");
   $empl="create table empl 
         (
           ename varchar(22) ,
           eno varchar(4), 
            salary int(5)  
             
           
              
          )";
      $res=mysql_query($empl) or die(mysql_error());  
      echo "databbase of emp is succesfully created thanks for creating</br>";



     $sql="insert into empl values('abc','ww',2004)";
      if(mysql_query("$sql"))
       {
          die("error ".mysql_error());
        }
      echo "1 record added";
     $ret=mysql_query("select * from empl");
     while($rows=mysql_fetch_array($ret))
    {
      echo  $rows['ename']. "   ".$rows['eno'];      
     echo "<br>";
    }
      mysql_close($con);
 ?>

its giving an error...
" databbase of emp is succesfully created thanks for creating
error "

the insertion is working well
please help me
thanks in advance

You need to be a bit precise with the number of rows when querying a DB.
Try this code... I hope this solves your problem beautifully...

$sql="insert into emp1 values('abc','1c1',2004)";
if(mysql_query("$sql"))
{
      echo "1 record added";
}else{
      die("error ".mysql_error());
}

$ret=mysql_query("select * from emp1");

while($rows=mysql_fetch_array($ret) >= 1)
{
echo $rows['ename']. " ".$rows['eno'];
echo "<br>";
}

thanks for the reply
the records are getting inserted into the table but i am facing a small problem with retireval..
the while loop is being executed but the values in the fields are not being printed...
see this code

<?php
  
  $con=mysql_connect("localhost","root","") or die("well please check ");
  if(mysql_query("create DATABASE hello"))
   {
       echo  "database created successfully";
   }
   mysql_select_db("hello");
   
    
   
   $sql="insert into empl values('abcdd','1c1',2004)";
if(mysql_query("$sql"))
{
      echo "1 record added";
}else{
      die("error ".mysql_error());
}

$ret=mysql_query("select * from empl");
echo "congrats";
while($rows=mysql_fetch_array($ret) >= 1)
{
echo $rows['ename']. " ".$rows['eno'];
echo "<br>";
}
   echo "haii";
      mysql_close($con);
 ?>

and the output is as the attached pic

while($rows=mysql_fetch_array($ret) >= 1)

this statement is not allowing the echo in while to print the values

i tried while($rows=mysql_fetch_array($ret) ) and it worked
what is the reason?
isnt that while($rows=mysql_fetch_array($ret) >= 1) correct?

mysql_fetch_array return a resource or false, and not a row count.

mysql_fetch_array returns the rows or false if there are no rows..
is it that?

Try using print_r($rows. " ".$rows); if this isn't working then give this a go...


while(mysql_affected_rows($ret)>=1){
DO SOMETHING;
}

Try using print_r($rows. " ".$rows);

this is working but its displaying only the first record in the table
and coming to this

while(mysql_affected_rows($ret)>=1){
DO SOMETHING;


its an error
the function should return a resource and we are comparing the resource with a numeric value which may not be appropriate..

can anyone help me in creating a generic page to all my web pages in some site i am trying to do.....
i want some means to have a page that works almost similar to that of master page in .net

thanks in advance

I prefer to use Smarty for that (a template engine), although there are several more (RainTPL for example).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.