New guy, used to asp - help appriciated...

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

phil speakman
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 9:25 am
Location: Liverpool

so mucj info

Post by phil speakman »

cheers all, i'm working my way through the info at a slow pace to try and pick it up along the way

quick question, what does this mean, or at least what do the <<<'s mean
echo <<< TABLE
cheers Phil
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

It's called heredoc

mwhahaha :lol:...

-Nay
phil speakman
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 9:25 am
Location: Liverpool

eerrrmmmm

Post by phil speakman »

ok digin it

var = this <<<
[......]
this

sticks the whole line[...] into a string called var, am i right

if so what are the benefits - is it the wholw double quote single quote nightmare?
I await with baited breath
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

This is wrong!

Code: Select all

var = this <<<
[......]
this
This is right:

Code: Select all

var = <<< THIS
[......]
THIS
<<< should come first, and it is more advisible to use CAPS. Since this might happen sometimes:

Code: Select all

var = <<< this
this is a sentence!
this
So it'll get PHP confused, since it'll end on the first "this" it sees and "is a sentence" and "this" would cause an error.

-Nay
phil speakman
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 9:25 am
Location: Liverpool

cool

Post by phil speakman »

ok i understand
now i have ammended my code to be in line with yours and it is spitting out all values in database
as you can see, with LIKE
http://members.lycos.co.uk/philspeakman/send.asp
there is a pupil called sally johnson

and with WITH = it spits out none

hope i'm not doing your head in with all these questions.
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

mMm.......how does your script look like now?

-Nay
phil speakman
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 9:25 am
Location: Liverpool

like this

Post by phil speakman »

Code: Select all

<?php
		// storing a connection in a variable @ chills any errors
 $con = @mysql_connect("localhost","philspeakman","goatboy")or die(mysql_error()); ;
		// storing a db selection
 $db = @mysql_select_db("philspeakman_uk_db")or die(mysql_error()); 
 
 echo('<p>Here is a list of the images and classes that produced them.</p>
 <table>');
		// storing search term in var from address bar
 $search = "%" .$_POST&#1111;'pupil']."%";
 echo($search);
		// query get all from table where pupil = search term
 $qu = "SELECT * from alt_bridge_pupils WHERE pupil like '&#123;$search&#125;'"; 
		// result of query stored in result variable
$result = @mysql_query($qu,$con) or die (mysql_error());
		// while not eof fetch info from result store in row var
	while($row = mysql_fetch_array($result))&#123;
		echo('<tr><td>'.$row &#1111;'pupil'].'</td>');
	&#125;
  ?>
  </table>
as you can see i was using

Code: Select all

echo($search);
to check the variable state and it currently prints %%
and that ain't right.
Any thoughts?
Phil
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

I took out the @ so it does throw up an error. When you've got the script all working, then put back the @. Try this code:

Code: Select all

<?php

$con = mysql_connect("localhost","philspeakman","goatboy")or die(mysql_error());

$db = mysql_select_db("philspeakman_uk_db")or die(mysql_error());

echo "<p>Here is a list of the images and classes that produced them.</p><table>";

$search = "%" .$_POST['pupil']."%";
echo $search;

$qu = "SELECT * from alt_bridge_pupils WHERE pupil like '{$search}'";

$result = mysql_query($qu,$con) or die(mysql_error());

while($row = mysql_fetch_array($result)){
echo "<tr><td>" . {$row['pupil']} . "</td>";
}

?>
</table>
-Nay
phil speakman
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 9:25 am
Location: Liverpool

errmmmm2

Post by phil speakman »

without the @
error in line 23 which is echo line of this

Code: Select all

while($row = mysql_fetch_array($result))&#123;
		echo "<tr><td>" . &#123;$row&#1111;'pupil']&#125; . "</td>"; 	&#125;
what do the . and the "%" 's mean?
Post Reply