0

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

4
Contributors
21
Replies
24
Views
5 Years
Discussion Span
Last Post by pritaeas
0

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 :)

0

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..

0

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

0

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>";
}

Edited by rotten69: n/a

0

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

Attachments untitled.jpg 36.76 KB
0

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?

0

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


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

0

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..

Edited by sharathg.satya: n/a

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.