Page 2 of 2
so mucj info
Posted: Thu Oct 23, 2003 4:09 am
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
Posted: Thu Oct 23, 2003 4:40 am
by Nay
It's called
heredoc
mwhahaha

...
-Nay
eerrrmmmm
Posted: Thu Oct 23, 2003 4:49 am
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
Posted: Thu Oct 23, 2003 5:06 am
by Nay
This is wrong!
This is right:
<<< 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
cool
Posted: Thu Oct 23, 2003 5:27 am
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.
Posted: Thu Oct 23, 2003 5:38 am
by Nay
mMm.......how does your script look like now?
-Nay
like this
Posted: Thu Oct 23, 2003 6:17 am
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ї'pupil']."%";
echo($search);
// query get all from table where pupil = search term
$qu = "SELECT * from alt_bridge_pupils WHERE pupil like '{$search}'";
// 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)){
echo('<tr><td>'.$row ї'pupil'].'</td>');
}
?>
</table>
as you can see i was using
to check the variable state and it currently prints %%
and that ain't right.
Any thoughts?
Phil
Posted: Thu Oct 23, 2003 6:22 am
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
errmmmm2
Posted: Thu Oct 23, 2003 6:34 am
by phil speakman
without the @
error in line 23 which is echo line of this
Code: Select all
while($row = mysql_fetch_array($result)){
echo "<tr><td>" . {$rowї'pupil']} . "</td>"; }
what do the . and the "%" 's mean?