?
Solved

Php issue while displaying

Posted on 2012-08-30
8
Medium Priority
?
408 Views
Last Modified: 2012-08-30
Experts,
<?php
$connection=mysql_pconnect("100.100.100.30","root","root") or  die("Could not connect to the server.");
$db=mysql_select_db("test",$connection) or die("Could not select database");

$sql="select * from contacts";
$res=mysql_query($sql,$connection);
while($row=mysql_fetch_array($res))
{
 echo "$row['firstname'] ";
 echo "$row['lastname']";
 echo "$row['cell_no']";
 echo "<br>";
}
?>

while this piece of code i am getting

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\wamp\www\display.php on line
0
Comment
Question by:roy_sanu
  • 6
  • 2
8 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38349297
try

 <?php
$connection=mysql_pconnect("100.100.100.30","root","root") or  die("Could not connect to the server.");
$db=mysql_select_db("test",$connection) or die("Could not select database");

$sql="select * from contacts";
$res=mysql_query($sql,$connection) or die(mysql_error());
while($row=mysql_fetch_array($res))
{
 echo $row['firstname'];
 echo $row['lastname'];
 echo $row['cell_no'];
 echo "<br>";
}
?>

Open in new window

0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38349310
You should remove " quote around these fields,

echo "$row['firstname']";

It should be echo $row['firstname'];
0
 

Author Comment

by:roy_sanu
ID: 38349347
Warning: mysql_pconnect(): Host 'roy_SANU.esntechnology' is not allowed to connect to this MySQL server in C:\wamp\www\display.php on line 2

all Stack
#      Time      Memory      Function      Location
1      0.0006      247424      {main}( )      ..\display.php:0
2      0.0006      248296      mysql_pconnect ( )      ..\display.php:2
Could not connect to the server.

This is the error below

roy_sanu
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 2000 total points
ID: 38349359
then, it means "100.100.100.30" host is not allowed you to connect that mysql db server.

try to get the server host ? whether it is "localhost" or any other ip address or host name specific
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38349364
find out "Host 'roy_SANU.esntechnology' "  .. is the right host name to connect? or with PORT name etc.,
0
 

Author Comment

by:roy_sanu
ID: 38349455
I changed it to localhost instead of 100.100.100.30, it is working now

Thanks
roy_sanu
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 38349467
gr8
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question