new to php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

new to php

Post by cr-isp »

hi all,

im having a little problem with some coding i need to do, the problem lies i think with the fact im trying to echo out commands in an html table. the script just keeps bombing out. does any one have any idead hoe to fix this script.

many thanks in advance

Alan

script is as follows...

Code: Select all

<?PHP 
$cfgProgDir = crispsession/; 
include($cfgProgDir . secure.php);
?>

<html>

<head>
<meta http-equiv=Content-Language content=en-gb>
<meta http-equiv=Content-Type content=text/html; charset=windows-1252>
<title>New Page 1</title>
</head>

<?
    
mysql_connect(localhost,database,password);

$query1 = SELECT * FROM table WHERE username=$login and password=$password;
$result1 = mysql_db_query(database,$query1);
while($row = mysql_fetch_object($result1)) {

echo(

<body>

<table cellpadding=0 cellspacing=0 width=450>
	<!-- MSTableType=layout -->
	<tr>
		<td height=34 width=181>
		<p align=right><font face=Tahoma size=2>Test Php Table Echo</font></td>
		<td height=34 width=9> </td>
		<td height=34><font face=Tahoma size=2>Details</font></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181 valign=top align=right>
		<font face=Tahoma size=2>First Name:</font></td>
		<td height=13 width=9></td>
		<td height=13><font face=Tahoma size=2>$row->first_name</font></td>
	</tr>
	<tr>
		<td height=13 width=181 valign=top align=right>
		<font face=Tahoma size=2>Last Name:</font></td>
		<td height=13 width=9></td>
		<td height=13><font face=Tahoma size=2>$row->last_name</font></td>
	</tr>
	<tr>
		<td height=13 width=181 align=right><font face=Tahoma size=2> </font></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181 valign=top align=right>
		<font face=Tahoma size=2>Wireless Adapter:</font></td>
		<td height=13 width=9></td>
		<td height=13><font face=Tahoma size=2>$row->wireless_adapter</font></td>
	</tr>
	<tr>
		<td height=13 width=181 valign=top align=right>
		<font face=Tahoma size=2>Speed:</font></td>
		<td height=13 width=9></td>
		<td height=13><font face=Tahoma size=2>$row->speed</font></td>
	</tr>
	<tr>
		<td height=13 width=181 align=right><font face=Tahoma size=2> </font></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181 align=right><font face=Tahoma size=2> </font></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
	<tr>
		<td height=13 width=181></td>
		<td height=13 width=9></td>
		<td height=13></td>
	</tr>
</table>

</body>

</html>

);
    
 }
                
?>
Last edited by cr-isp on Thu May 26, 2005 8:38 am, edited 3 times in total.
cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

Post by cr-isp »

ive also removed the final " out of the script
i know the code i submitted had some left in it

Alan
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

see how nice the code looks now? Why is that? Because I added

Code: Select all

-tags[/url] around it. Next time you do it yourself. Saves your time, my time, and the time of the people who anwer. Wow. Amazing, innit?
cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

Post by cr-isp »

ahh right

cool, looks alot better now, easier to understand

thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

and what is your error?
User avatar
artexercise
Forum Commoner
Posts: 33
Joined: Thu Nov 20, 2003 9:38 am
Location: Raleigh, NC

Post by artexercise »

First on line 22 and line 204 of the above code.
Line 22 needs to have an open quote such as
echo ("
Line 204 needs to close that quote
");

JOE--
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

This function is deprecated, do not use this function. Instead, use mysql_select_db() and mysql_query() instead.
for mysql_db_query

from php.net

also

Code: Select all

$query1 = "SELECT * FROM table WHERE username='$login' and password='$password'";
put quotes around your query.

what is this "bombing out" that your script does, be specific
cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

Post by cr-isp »

sorry should of said what was specific, my php ini file has error checking turned off so the white page is all i get, i have seen error checking done by using echo commands for each step.

will try points above and get back to you all

many thanks for the speedy response, a little over whelmed how helpfull and quick every one is.

tarrrr for now

Alan
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

put this at the top of your script

Code: Select all

error_reporting(E_ALL);        // error reporting set to display all
cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

Post by cr-isp »

did a find and replace on " thats wht line 22 and 204 were lissing open and close statements

Alan
cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

Post by cr-isp »

tried all suggested and still its not working, even the error checking has not worked when inserting it at th top of the page.

open to more suggestions

Alan
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

line 2:

Code: Select all

$cfgProgDir = "crispsession/";
You want to assign a string to $cfgProgDir.
cr-isp
Forum Newbie
Posts: 17
Joined: Thu May 26, 2005 8:25 am
Location: manchester

Post by cr-isp »

code looks like this

Code: Select all

<?PHP 
$cfgProgDir = session/; 
include($cfgProgDir . secure.php);
// error reporting set to display all
error_reporting(E_ALL);        
?>

<html>

<head>
<meta http-equiv=Content-Language content=en-gb>
<meta http-equiv=Content-Type content=text/html; charset=windows-1252>
<title>New Page 1</title>
</head>

<?
    
mysql_connect(localhost,database,password);

$query1 = "SELECT * FROM table WHERE username='$login' and password='$password'";
$result1 = mysql_db_query(databsse,$query1);
while($row = mysql_fetch_object($result1))  {

echo("
thats the top part

and the bottom is finshed like this

Code: Select all

");
    
 }
                
?>
and trying to echo feilds out in the table looks like this

Code: Select all

<tr>
  <td height=13 width=181 valign=top align=right>
  <font face=Tahoma size=2>First Name:</font></td>
  <td height=13 width=9></td>
  <td height=13><font face=Tahoma size=2>$row-  >first_name</font></td>
</tr>
any ideas now guys
Last edited by cr-isp on Thu May 26, 2005 9:28 am, edited 1 time in total.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

patrikG wrote:line 2:

Code: Select all

$cfgProgDir = "crispsession/";
You want to assign a string to $cfgProgDir.
you gotta put the quotes around the $cfgProgDir value
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

1. read my previous post
2. Error reporting doesn't work properly if you insert it after the erroneous PHP.

Use this

Code: Select all

error_reporting(E_ALL);        
$cfgProgDir = "crispsession/"; 
include($cfgProgDir . secure.php);
// error reporting set to display all
Post Reply