[PHP] MySQL connect used to work PLUS errors not displaying

2007-08-24 Thread Linux NG/Lists
I swear, it was just working last week! Well, a while ago, on another 
machine. You get the idea. Here's the deal...


PHP 5.1.6 and MySQL 5.x on FC6 fully patched.

1. A simple page with a call to phpinfo() works fine.

2. A barely more complicated page also works fine, in that it throws an 
expected error:


?php
error_reporting(E_ALL);
ini_set('display_errors','On');
dsjdlfjsldfjs;
phpinfo();
?

returns

Notice: Use of undefined constant dsjdlfjsldfjs - assumed 
'dsjdlfjsldfjs' in index.php on line 22.


(thanks to another message that suggested adding the calls directly into 
the page when error reporting in php.ini seems to be ignored).


Then the phpinfo data displays.

3. BUT, a call to a MySQL database:

?php
error_reporting(E_ALL);
ini_set('display_errors','On');
@ $db=new mysqli('localhost','whil','secret','test');
if (mysqli_connect_errno())
{echo 'Error ­ could not connect to database.';
exit;
}
?

results in a blank page. No errors, no warnings, no nothing. I have 
confirmed through the Query Browser that the credentials passed are good 
and result in access to the test database on localhost.


So two things seem broken:

a) The connect doesn't work. I have done this oodles of times before, 
although not on this particular machine. I'm thinking there's a config 
issue with mysqli but I dunno what. The config from phpinfo is below.


b) Why does the error reporting NOT work as soon as I jam a $db new 
mysql call into the code?


Thanks,
Whil

phpinfo() reports this configure script:

'./configure' '--build=i686-redhat-linux-gnu' 
'--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' 
'--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' 
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' 
'--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' 
'--libexecdir=/usr/libexec' '--localstatedir=/var' 
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man' 
'--infodir=/usr/share/info' '--cache-file=../config.cache' 
'--with-libdir=lib' '--with-config-file-path=/etc' 
'--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' 
'--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' 
'--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' 
'--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' 
'--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' 
'--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' 
'--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' 
'--enable-exif' '--enable-ftp' '--enable-magic-quotes' 
'--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' 
'--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' 
'--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' 
'--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' 
'--enable-calendar' '--enable-dbx' '--enable-dio' 
'--with-mime-magic=/usr/share/file/magic' '--without-sqlite' 
'--with-libxml-dir=/usr' '--with-xml' '--with-apxs2=/usr/sbin/apxs' 
'--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' 
'--disable-dba' '--without-unixODBC' '--disable-pdo' 
'--disable-xmlreader' '--disable-xmlwriter'


// end

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL connect used to work PLUS errors not displaying

2007-08-24 Thread Linux NG/Lists

comex wrote:

On 8/24/07, Linux NG/Lists [EMAIL PROTECTED] wrote:


b) Why does the error reporting NOT work as soon as I jam a $db new
mysql call into the code?

Because you disabled it with an '@'.




Well, I suppose I should say Doh! but even when I get rid of the 
@, I still get a blank page - no errors, and no database, either!


Whil

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] MySQL connect used to work PLUS errors not displaying

2007-08-24 Thread Linux NG/Lists


Well, I suppose I should say Doh! but even when I get rid of the 
@, I still get a blank page - no errors, and no database, either!


A followup - I'm taking this over to PHP-DB since it's now 
database-centric, I think.


This still fails:
  $db = new mysqli(

But this works
  $conn = mysqli(...

See you on that list.

Whil

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Newbie Define Paths question

2005-03-31 Thread Jackson Linux
Hi,
I've set the following:
$nscfg['url'] ='http://www.domain.com/';
$nscfg['secure_url'] ='https://domain.com/';
$nscfg['site root'] = '/Users/username/public_html/';
$nscfg['base'] = 'http://www.domain.com/';
// For use in the HTML documents
define (URL, $nscfg['url']);
// where to find Articles
define (ARTICLES,$nscfg['url'].articles/);
// where to find Books
define (BOOKS, $nscfg['url'].books/);
// where to find Resume
define (CV, $nscfg['base'].cv/);
// where to find the various types of PHP includes ie sidebars
define (INCLUDES, $nscfg['site root'].docs/);
And things like this:
a class='credits-link' href='?php echo URL ?forms/mailform.htm' 
title=Email Me
target='_blank'click/a

 work great.
What am I doing wrong when I try to make this:
?php include_once INCLUDES.include.php; ?
work?
Thanks in advance!
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] URL file-access disabled

2005-03-31 Thread Jackson Linux
Hi, ho,
I have a problem; something which works locally is complaining on the 
BSD Unix server I use:

The Code: (somewhere else I define $image_dir)
!-- If there's an image, get it, get its height and width and slap it 
into an image tag, otherwise, move on  --
?php if (!empty($article['image']))  {
$image = ($article['image']);
$size1 = getimagesize($image_dir.$image);
$width1 = $size1[0];
$height1 = $size1[1];

include_once(INCLUDES . 'image.include.php');
}
?
The Include:
img class='right-float' src='?php echo $image_dir.$image ?' 
width='?php echo $width1 ?' height='?php echo $height1 ?' 
alt='?php echo $image ?' border='0' /

The Error:
Warning: getimagesize(): URL file-access is disabled in the server 
configuration in /usr/www/users/user/articles/technology/index.htm on 
line 180

Warning: 
getimagesize(http://www.domain.com/images/combination_device.jpg): 
failed to open stream: no suitable wrapper could be found in 
/usr/www/users/user/articles/technology/index.htm on line 180

The Question:
Anything I can do within .htaccess to make this not happen? I don't 
have root access or access to php.ini, and they're loathe to change the 
configuration  on a shared servcer.

Thanks in advance,
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] URL file-access disabled

2005-03-31 Thread Jackson Linux
My provider has provided me the solution: adding
php_flag allow_url_fopen on
to the .htaccess
Apologies to the list for wasting time and bandwidth.
Jack
On 31 Mar 2005, at 17:47, Jackson Linux wrote:
Hi, ho,
I have a problem; something which works locally is complaining on the 
BSD Unix server I use:

The Code: (somewhere else I define $image_dir)
!-- If there's an image, get it, get its height and width and slap it 
into an image tag, otherwise, move on  --
?php if (!empty($article['image']))  {
$image = ($article['image']);
$size1 = getimagesize($image_dir.$image);
$width1 = $size1[0];
$height1 = $size1[1];

include_once(INCLUDES . 'image.include.php');
}
?
The Include:
img class='right-float' src='?php echo $image_dir.$image ?' 
width='?php echo $width1 ?' height='?php echo $height1 ?' 
alt='?php echo $image ?' border='0' /

The Error:
Warning: getimagesize(): URL file-access is disabled in the server 
configuration in /usr/www/users/user/articles/technology/index.htm on 
line 180

Warning: 
getimagesize(http://www.domain.com/images/combination_device.jpg): 
failed to open stream: no suitable wrapper could be found in 
/usr/www/users/user/articles/technology/index.htm on line 180

The Question:
Anything I can do within .htaccess to make this not happen? I don't 
have root access or access to php.ini, and they're loathe to change 
the configuration  on a shared servcer.

Thanks in advance,
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] NEWBIE: Can't Get My Loop Going. . .

2005-03-29 Thread Jackson Linux
As usual, Jochem, thanks for all those useful tips. They are much 
appreciated.

Jack
On 29 Mar 2005, at 05:15, Jochem Maas wrote:
Jackson Linux wrote:
Hello all,
I am a newbie trying to build a set of links to content in a db. I am 
connecting with the db and seeing the proper number of rows. if I 
echo out the values of $id and $sidebar I see that they take on the 
id# and text of the last entry in the database. I'm trying to make 
the script get each of the rows, until there are no more, and echo 
out the info I need for each row. Please can someone tell me where 
I'm going wrong?
(the variables spelling out the db connection information are in a 
prepend file, and work.)
I read that you already figured it out... thought I add a couple of
general tips:
Thanks in advance,
Jack
?php
$conn = mysql_connect($dbserver, $dbusername, $dbpassword);
if (!$conn) {
if you don't intend to use the $conn var why initialize it?:
mysql_connect($dbserver, $dbusername, $dbpassword) or die(Unable to 
connect to DB:  . mysql_error());

  echo Unable to connect to DB:  . mysql_error();
  exit;
}
if (!mysql_select_db($dbname)) {
  echo Unable to select mydbname:  . mysql_error();
  exit;
}
$sql = 
SELECT *
FROM sidebar
;
$sidebar = array();
$result = mysql_query($sql);
if (!empty($result)) {
again if you are using $sql only in one place then there
 is no reason to not to do the following instead (given that
the query itself is very short - i.e. legibility is not a problem):
if ($result = mysql_query(SELECT * FROM sidebar)) {

 while ($sidebar = mysql_fetch_assoc($result)) {
$id = $sidebar['sidebar_id'];
$linktext = $sidebar['headline'];
sometimes it handy to initialize vars like the 2 above for 
readability...
in this case you may consider that the expressions are very short and 
therefore
you might want to skip creating the vars:

$left_sidebar[] = li class='menu-item'- a class='sidebar-link'
href='{$_SERVER['PHP_SELF']}?s={$sidebar['sidebar_id']}'
title=\{$sidebar['headline']}\{$sidebar['headline']}/a/li;

/* Build sidebar.*/
$left_sidebar[] = li class='menu-item'- a 
class='sidebar-link' href='{$_SERVER['PHP_SELF']}?s={$id}' 
title=\{$linktext}\{$linktext}/a/li;
}
}
else {}
the preceding empty else statement if not required you can leave out
the 'else {}' completely.
have fun. :-)
mysql_free_result($result);
?
htmlbody
 ul?php join(\n\n, $left_sidebar);  ?/ul
/body/html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] NEWBIE: Can't Get My Loop Going. . .

2005-03-28 Thread Jackson Linux
Hello all,
I am a newbie trying to build a set of links to content in a db. I am 
connecting with the db and seeing the proper number of rows. if I echo 
out the values of $id and $sidebar I see that they take on the id# and 
text of the last entry in the database. I'm trying to make the script 
get each of the rows, until there are no more, and echo out the info I 
need for each row. Please can someone tell me where I'm going wrong?
(the variables spelling out the db connection information are in a 
prepend file, and work.)

Thanks in advance,
Jack
?php

$conn = mysql_connect($dbserver, $dbusername, $dbpassword);
if (!$conn) {
  echo Unable to connect to DB:  . mysql_error();
  exit;
}
if (!mysql_select_db($dbname)) {
  echo Unable to select mydbname:  . mysql_error();
  exit;
}
$sql = 
SELECT *
FROM sidebar
;
$sidebar = array();
$result = mysql_query($sql);
if (!empty($result)) {
 while ($sidebar = mysql_fetch_assoc($result)) {
$id = $sidebar['sidebar_id'];
$linktext = $sidebar['headline'];
/* Build sidebar.*/
$left_sidebar[] = li class='menu-item'- a class='sidebar-link' 
href='{$_SERVER['PHP_SELF']}?s={$id}' 
title=\{$linktext}\{$linktext}/a/li;

}
}
else {}
mysql_free_result($result);
?
htmlbody
 ul?php join(\n\n, $left_sidebar);  ?/ul
/body/html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] NEWBIE: Can't Get My Loop Going. . .

2005-03-28 Thread Jackson Linux
Sorry folks. I have been told by a more knowledgeable friend that the 
problem was I forgot to ECHO out the join. It works now.

Thanks anyway!!
Jack
On 28 Mar 2005, at 15:57, Jackson Linux wrote:
Hello all,
I am a newbie trying to build a set of links to content in a db. I am 
connecting with the db and seeing the proper number of rows. if I echo 
out the values of $id and $sidebar I see that they take on the id# and 
text of the last entry in the database. I'm trying to make the script 
get each of the rows, until there are no more, and echo out the info I 
need for each row. Please can someone tell me where I'm going wrong?
(the variables spelling out the db connection information are in a 
prepend file, and work.)

Thanks in advance,
Jack
?php

$conn = mysql_connect($dbserver, $dbusername, $dbpassword);
if (!$conn) {
  echo Unable to connect to DB:  . mysql_error();
  exit;
}
if (!mysql_select_db($dbname)) {
  echo Unable to select mydbname:  . mysql_error();
  exit;
}
$sql = 
SELECT *
FROM sidebar
;
$sidebar = array();
$result = mysql_query($sql);
if (!empty($result)) {
 while ($sidebar = mysql_fetch_assoc($result)) {
$id = $sidebar['sidebar_id'];
$linktext = $sidebar['headline'];
/* Build sidebar.*/
$left_sidebar[] = li class='menu-item'- a class='sidebar-link' 
href='{$_SERVER['PHP_SELF']}?s={$id}' 
title=\{$linktext}\{$linktext}/a/li;

}
}
else {}
mysql_free_result($result);
?
htmlbody
 ul?php join(\n\n, $left_sidebar);  ?/ul
/body/html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Question - an If in an Array?

2005-03-28 Thread Jackson Linux
I'm so confused. I have an array :
$display[]  = 
div class='job-date'{$cv['dates']}/div
div class='job-title'{$cv['job_title']}/div
div class='company'{$cv['company']}/div
div class='job'{$cv['job']}/div;
In SOME of the rows of this table, there is a field called sidebar. I'd  
like to have this array include a reference to this field if it exists.

I was thinking something like:
if (!empty($cv['sidebar'])){
	$sidebar_ref = 
  div class='sidebar_ref_box'a  
href='../sidebars/index.htm?s={$cv['sidebar']}' title='Sidebar'Learn  
More/a/div
	};

Can anyone offer some help?
Thanks. The whole script is below:


?php
/* invalid or missing GET? */
if (!isset($_GET['r']) || empty($_GET['r']) || !($r =   
intval($_GET['r']))) {
// show a plain vanilla index
include('/path/to/docs/cv.include.php');
exit;
}


/* With a valid $r, make some variables to help build the SQL query
 * Note three conditions join the tables yes we are aware of that */
$fields=   
'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,cv.si 
debar,jobcat.category';
$where = WHERE cvjobcats.cv_id=cv.cv_id
	  AND cvjobcats.jobcat_id = '$r'
  AND jobcat.jobcat_id=cvjobcats.jobcat_id;
$restables = cv, cvjobcats, jobcat;
$sort  = ORDER BY cv.sort;

/* Finally the actual SQL query, using the variables just set
 * do we have a valid mysql result resource?
 */
if (!($result = mysql_query(SELECT $fields FROM $restables $where  
$sort))) {
  echo Could not successfully run query ($sql) from DB:  .   
mysql_error();
  exit;
}

/* do we have any records? if not show the list/menu */
if (mysql_num_rows($result) == 0) {
  include_once('/path/to/docs/cv.include.php');
  exit;
}
$display = array();  // this is merely an array initialization
unset($cat);
while ($cv = mysql_fetch_assoc($result)) {
/* set the category name for display in the output */
if (!isset($cat)) {
$cat = $cv['category'];
}
/*$sidebar_ref = array();
while ($cv = mysql_fetch_assoc($result)) {
  if (!empty($cv['sidebar'])){
	$sidebar_ref [] = 
  div class='sidebar_ref_box'a  
href='../sidebars/index.htm?s={$cv['sidebar']}' title='Sidebar'Learn  
More/a/div
	};
}*/

/* make an array of jobs which includes the HTML to be displayed
 * in the HTML page when we make one...
 */
$display[]  = 
div class='job-date'{$cv['dates']}/div
div class='job-title'{$cv['job_title']}/div
div class='company'{$cv['company']}/div
div class='job'{$cv['job']}/div;
}
/* be nice - tell mysql to free the resultset */
mysql_free_result($result);
/*
 * And now, wrap up the PHP and make the page...
 */
echo ?xml version='1.0' ?\n;
?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN  
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
		titleResume /title
		link rel='stylesheet' href='http://domain.com/docs/style.css'   
type='text/css' /
	/head
body

!-- CALL EVERYTHING BELOW A PAGE --
div id='page-display'
!--START HEADER --?php include_once  
/path/to/docs/header.include.php ?!-- END HEADER  --

!-- BEGIN LEFT SIDE --
div id='left-sidebar'
?php include_once /path/to/docs/left-sidebar.cv.include.php; ?
/div
!-- END LEFT SIDE --
!--START MAIN CONTENT AREA--
div id='content'

h1Reacute;sumeacute;/h1
?php include_once /path/to/docs/cv.$r.include.php; ?
div class='job-category'?php echo $cat?/div

?php
if (sizeof($display)) {
echo 
div id='table-of-contents'
;
echo join(\n\t\t, $display);
echo 
/div
;
}

?
/div
!--END MAIN CONTENT AREA--
!--BEGIN FOOTER--
div id='footer'?php include_once /path/to/docs/footer.include.php  
?/div
!--END FOOTER--

/div
!--END PAGE--
/body
/html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread Jackson Linux
Hi, everyone, I apologise if this posts twice; I'm having issues with 
my outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some 
articles. This works great:

$content = strip_tags($article['content']);
$striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250 
characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?
Thanks in advance,
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread Jackson Linux
Hi, everyone,
I'm 'teasers' of the first, say 200 to 250 characters of some articles. 
This works great:

$content = strip_tags($article['content']);
$striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250 
characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?
Thanks in advance,
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question: breaking a substr() string on a space SOLVED

2005-03-11 Thread Jackson Linux
Hi, everyone,
Thanks for the great suggestions! I've looked at all and found that the 
one here:

http://www.php.net/explode
that Jay recommended was the easiest for me to wrap my brain around. I 
wll tinker with the other ones as well - it's all really interesting.

The function was:
function wordlimit($string, $length = 50, $ellipsis = ...)
{
   $paragraph = explode( , $string);
   if($length  count($paragraph))
   {
   for($i = 0; $i  $length; $i++)
   {
   if($i  $length - 1)
   $output .= $paragraph[$i] .  ;
   else
   $output .= $paragraph[$i] . $ellipsis;
   }
   return $output;
   }
   return $string;
}
And boy does it work easily!!!
Thanks again all who replied.
Jack


On 11 Mar 2005, at 12:36, Richard Lynch wrote:

Hi, everyone,
I'm 'teasers' of the first, say 200 to 250 characters of some 
articles.
This works great:

 $content = strip_tags($article['content']);
 $striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250
characters, then count backwards to the last space and chop it there.
Does anyone have an ideas/scripts for this?
$pos = strpos($content, ' ');
$pos = $pos ? $pos : strlen($content);
$teaser = substr($content, 0, $pos);
--
Like Music?
http://l-i-e.com/artists.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Question re empty query

2005-03-10 Thread Jackson Linux
On 10 Mar 2005, at 07:38, Jochem Maas wrote:
Jackson Linux wrote:
Okay, guys,
I hope I'm getting closer with your help here but I am still highly   
confused (that's actually a general blanket statement these days).
I've taken your advice and made several changes,
On 9 Mar 2005, at 13:44, Jochem Maas wrote:
M. Sokolewicz wrote:
Jackson Linux wrote:
Hi,
This:
if (isset($_GET['r']) 
 !empty($_GET['r']) 
 ($r = intval($_GET['r'])) ){

does nobody notice the last 'bit' of the if expression??
if the IF statement evaluates to true then $r _has_ been set!!!
That makes sense now.

$r = {$_GET['r']}; //Set the variable $r to mean the category   
number
gods, that's an ugly statement... why don't you simply use $r =   
$_GET['r']; 

that leaves him completely open to SQL injection.
but your right in that writing this:
$r = {$_GET['r']};
... is just plain wasteful, pointless and looks ugly.
and given the fact that $r is already set (see above) there is
no need to set it again at all.
I see that now; thanks, I removed  it
I think you almost there Jackson, keep hacking :-)
Thanks for the encouragement! But there's more...
$sort = ORDER BY cv.sort;
} else {
$where = '';
$fields =
'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort, 
   jobcat.category';
$sort = ORDER BY cv.sort;
}

//Make the sql based on the joining of the table and intersection   
table
$sql = 
SELECT
cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,j 
ob cat .category
FROM cv, cvjobcats, jobcat
WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND
jobcat.jobcat_id=cvjobcats.jobcat_id;

Works whenever there is an ?r= specified. When there is no r   
specified  it chokes on

WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND
jobcat.jobcat_id=cvjobcats.jobcat_id;

because there's no value to $r.
it also opens me up to allowing anyone to state *anything* after  
the  ?.

So can I make an else statement which will say that if there's no  
r=  or  a wrong r= or even no ? at all then it should print a menu  
to  $r's  which actually exist in the database? How?

Thanks in advance!!!
You have 3 conditions in a single expression. Split that expression  
up

Jackson got that bit from me - I don't think he is fully aware of  
what  that
expression is doing!

the 'sum' of those conditions determines that either $r is 'good' or  
 'bad'
(whether $r is garbage or not set didn't seem like a difference  
worth  bothering
with)

No, I didn't and I actually still don't. I've implemented the change   
below, breaking up the if(isset)$_GET['r']) bit (making it easier to   
follow indeed, thank you!) but I am confused as to how to break that   
three-condition statement split based on that change.
into multiple expressions, so you can check each (or a combination  
of  2) individually.

this is a good idea to better understand what is going on!
so, instead of:
if (isset($_GET['r'])  !empty($_GET['r'])  ($r =   
intval($_GET['r']))){
do:
if (isset($_GET['r'])) {
if(!empty($_GET['r'])  ($r = intval($_GET['r']))){
// do whatever
} else {
// something boring
}
} else {
// not set
}

The code below is where I am now.  I'm trying to document a bit  
better,  and clean it up. And I still don't have any clue as to how  
to make it  redirect if someone requests no ?r=  or a bad one. Can  
someone help  please?
snip
if (isset($_GET['r'])) {
if(!empty($_GET['r'])  ($r = intval($_GET['r']))){
  $fields = '*';
  $where = WHERE cvjobcats.cv_id=cv.cv_id AND  
cvjobcats.jobcat_id =  '$r' AND  
jobcat.jobcat_id=cvjobcats.jobcat_id;
  $sort = ORDER BY cv.sort; // Assemble the category items  
in  r=x
} else {
// Is this where I'd say IF no $r is set then redirect?
}
}
all you need is 1 if (or if/else) statement, note that my example
is the logical reverse of the first if statement I posted (in reply
to your question):
if (!isset($_GET['r']) || empty($_GET['r']) || !($r =  
intval($_GET['r']))) {
	// _GET['r'] is either not set, empty or not a positive int greater  
than zero.
// the required var is 'bad' so lets redirect the user.
	if (!headers_sent()) {
		header('location: /yourRvarsucks.php');
	} else {
		// you'll have to figure out what to do yourself
		// if you want to redirect and headers have already been sent!
		
	}
	exit;
}

// now comes the rest of the script (build SQL, run it, output the  
data)

$where = WHERE cvjobcats.cv_id=cv.cv_id
  AND cvjobcats.jobcat_id = '$r'
  AND jobcat.jobcat_id=cvjobcats.jobcat_id;
$sort  = ORDER BY cv.sort;
// etc etc ...
Whhooo.
I created this:
$badr =  )
1. I believe that this:
if (!isset($_GET['r']) || empty($_GET['r']) || !($r =  
intval($_GET['r']))) {
	// _GET['r'] is either not set, empty or not a positive int greater  
than zero.
// the required var is 'bad' so lets redirect the user.
	if (!headers_sent()) {
		header('location: {$_SERVER['PHP_SELF

Re: [PHP] Re: Question re empty query SOLVED

2005-03-10 Thread Jackson Linux
Hi, Jochem and everyone
This:
On 10 Mar 2005, at 15:23, Jochem Maas wrote:
if (!isset($_GET['r']) || empty($_GET['r']) || !($r = 
intval($_GET['r'])))
{
	// show a list of R's
	include('showlist.inc.php');
}
else
{
	// process an R
	include('process.inc.php');
}

Solved my issue entirely, as did Jochem's patient assistance for the 
past three days and your tolerance. You'll all be pleased to know of my 
recent purchase of PHP My Sql for Dummies and PHP5/MySql Programming 
for the absolute beginner noteI am not connected in any way with the 
publishers, authors, distributors or retailers of these books and this 
is not an endorsement /note. Thanks for the help!

Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie LEFT JOIN question

2005-03-09 Thread Jackson Linux
First, I apologize - I'm new to this, grateful for the list and just 
confused. I didn't mean to post improperly.

Second, thanks so much Rory for simplifying it and answering that 
anyway.  I promise I wasn't going for technical impressiveness and 
easier is definitely better!

Thanks again,
Jack
On 9 Mar 2005, at 02:19, Rory McKinley wrote:
Jackson Linux wrote:
Hi, all,
I have three tables; 'cv', the main table, 'jobcat', a definition 
table and 'cvjobcats',  an intersection table (for more detail see PS 
below).
I'd like to join this all together to be able to make a headline 
consisting of the plain English description of the job category 
followed by all rows within cv which contain a reference to that job 
category
I can follow this only to a point and that is where I ask for the 
List's help - does this even resemble the beginnings of what I want 
to accomplish? I've tried to comment as I go for my own sanity
//Select columns from 'cv', whose 'category' references numbers
//Select 'category' from 'jobcat' to translate the numbers to English
SELECT cv.cv_id,
 cv.category,
dates,
cv.job_title,
cv.company,
cv.job,
 jobcat.category
FROM cv
LEFT JOIN cvjobcats
 ON cvjobcats.cv=cv.cv_id //Let tables cv and jobcat understand each 
other.
//This next bit I'm confused about
LEFT JOIN jobcat
 ON jobcat.jobcat_id=cvjobcats.jobcat
WHERE
 cvjobcats.jobcat='4';
Great. I'm now lost. Can anyone advise?
Thanks in advance,
PS:
 far too much information
cv contains columns including an primary key ('cv_id') and a column 
called 'category' which refers to job categories by number.
jobcat contains two fields: a primary key (jobcat_id) and a plain 
english description
cvjobcat contains two key columns: 'cv_id' and 'jobcat_id'.
/far too much information
Hello Jackson
Are there any circumstances under which the cvjobcats table would have 
a job category entry that does not appear in the jobcats table? IF 
not, you really don't need to use the LEFT JOINS. Instead you coudl do 
something like this:

SELECT cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job, 
jobcat.category
FROM cv, cvjobcats, jobcats
WHERE cvjobcats.cv=cv.cv_id AND cvjobcats_jobcat = 4 AND 
jobcat.jobcat_id=cvjobcats.jobcat

Less technically impressive perhaps but easier to follow ;)
Regards
Rory

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Variable Question

2005-03-09 Thread Jackson Linux
Hi, All,
A php variable question.
I've done this to take the requested category from the URL  
(www.foo.com/file.htm?r=1)
and use it to build the page:

if (isset($_GET['r'])  !empty($_GET['r'])) {
$r = '{$_GET['r']}'; //Set the variable $r to mean the category number
$fields = '*';
} else {
$where = '';
$fields =  
'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,  
jobcat.category';
$sort = ORDER BY cv.sort;
}

$sql = 
SELECT  
cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,jobcat 
.category
FROM cv, cvjobcats, jobcat
WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND  
jobcat.jobcat_id=cvjobcats.jobcat_id;

In this case $r comes out literally to the number surrounded by single  
quotes (ie, '1'). And it works great.

But I need *just* the number for something later (to fetch an include  
based on the category selected by $r). Since I've set the value of the  
field cv.category to mean the english translation from the intersecting  
table, using

php include_once /path/to/cv.$r.include.php; ? asks for  
cv.'1'.include.php ... And I need it to ask for cv.1.include.php

How can I make a variable to fetch the literal number from the field  
cv.category?

Thanks in advance!
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Newbie Variable Question

2005-03-09 Thread Jackson Linux
On 9 Mar 2005, at 11:15, Jason Barnett wrote:
Jackson Linux wrote:
...
php include_once /path/to/cv.$r.include.php; ? asks for
cv.'1'.include.php ... And I need it to ask for cv.1.include.php
How can I make a variable to fetch the literal number from the field
cv.category?
Not 100% certain that it will work, but try casting the variable $r to
an integer:
?php include_once /path/to/cv. . (int) $r . .include.php; ?

H. If  only. . .This returns, regardless of input and the value of 
$r

cv.0.include.php'
 For chuckles, I did check and the column is set in the table as INT.  
If that matters.
...?

Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Newbie Variable Question

2005-03-09 Thread Jackson Linux
Jochem and everyone,
Thanks, this solved the problem.
Regarding someone's much appreciated comment:
snip[this]...allows any user to simply change the value of r to 
something more to
their liking. given the reset of the code that you included in your
first message, who knows what nice holes they'll find in your code when
they do that. depending on where you go with this, they could end up
with information for/about another user, a nice sql injection on your
database, the ability to hack your system, or something else equally
amusing./snip

I agree, and actually had thought of it. I appreciate your reminding 
me. Because I am new enough that I still find a magical thrill every 
time I pull *anything* from the database, I have been approaching this 
from this point of view:

1. Make db
2. Try to get page to connect
3. Try to print what I want by setting the variable $r so I can point 
to it
4. Fix it so that if someone asks for anything other than an existent 
?r=x  it kicks back a webpage which just shows links to existing pages.

Which brings me to the next question, which I'll post in a second!
Thanks again everyone!
--Jack
On 9 Mar 2005, at 11:43, Jochem Maas wrote:
Jackson Linux wrote:
On 9 Mar 2005, at 11:15, Jason Barnett wrote:
Jackson Linux wrote:
...
php include_once /path/to/cv.$r.include.php; ? asks for
cv.'1'.include.php ... And I need it to ask for cv.1.include.php
How can I make a variable to fetch the literal number from the field
cv.category?

Not 100% certain that it will work, but try casting the variable $r 
to
an integer:

?php include_once /path/to/cv. . (int) $r . .include.php; ?

H. If  only. . .This returns, regardless of input and the value 
of $r
cv.0.include.php'
 For chuckles, I did check and the column is set in the table as INT. 
 If that matters.
not really - what matters is that you understand typecasting in php.
a string when cast to an integer will always be zero unless the string
begins with numeric chars, in which case php will take all the numeric 
chars
it finds until it comes across a char that is not numeric and return 
those chars
(I don't know exactly how it handles decimal points and minus signs in 
such as case)

echo (int) 1string;
echo (int) string1;
...?
Jack

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Question re empty query

2005-03-09 Thread Jackson Linux
Hi,
This:
if (isset($_GET['r']) 
 !empty($_GET['r']) 
 ($r = intval($_GET['r'])) ){
$r = {$_GET['r']}; //Set the variable $r to mean the category number
$fields = '*';
$sort = ORDER BY cv.sort;
} else {
$where = '';
$fields =  
'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,  
jobcat.category';
$sort = ORDER BY cv.sort;
}

//Make the sql based on the joining of the table and intersection table
$sql = 
SELECT  
cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,jobcat 
.category
FROM cv, cvjobcats, jobcat
WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND  
jobcat.jobcat_id=cvjobcats.jobcat_id;

Works whenever there is an ?r= specified. When there is no r specified  
it chokes on

WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND  
jobcat.jobcat_id=cvjobcats.jobcat_id;

because there's no value to $r.
it also opens me up to allowing anyone to state *anything* after the ?.
So can I make an else statement which will say that if there's no r= or  
a wrong r= or even no ? at all then it should print a menu to $r's  
which actually exist in the database? How?

Thanks in advance!!!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Question re empty query

2005-03-09 Thread Jackson Linux
Okay, guys,
I hope I'm getting closer with your help here but I am still highly  
confused (that's actually a general blanket statement these days).

I've taken your advice and made several changes,
On 9 Mar 2005, at 13:44, Jochem Maas wrote:
M. Sokolewicz wrote:
Jackson Linux wrote:
Hi,
This:
if (isset($_GET['r']) 
 !empty($_GET['r']) 
 ($r = intval($_GET['r'])) ){
does nobody notice the last 'bit' of the if expression??
if the IF statement evaluates to true then $r _has_ been set!!!
That makes sense now.

$r = {$_GET['r']}; //Set the variable $r to mean the category  
number
gods, that's an ugly statement... why don't you simply use $r =  
$_GET['r']; 
that leaves him completely open to SQL injection.
but your right in that writing this:
$r = {$_GET['r']};
... is just plain wasteful, pointless and looks ugly.
and given the fact that $r is already set (see above) there is
no need to set it again at all.
I see that now; thanks, I removed  it
I think you almost there Jackson, keep hacking :-)
Thanks for the encouragement! But there's more...
$sort = ORDER BY cv.sort;
} else {
$where = '';
$fields =   
'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,   
jobcat.category';
$sort = ORDER BY cv.sort;
}

//Make the sql based on the joining of the table and intersection  
table
$sql = 
SELECT   
cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,job 
cat .category
FROM cv, cvjobcats, jobcat
WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND   
jobcat.jobcat_id=cvjobcats.jobcat_id;

Works whenever there is an ?r= specified. When there is no r  
specified  it chokes on

WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id = $r AND   
jobcat.jobcat_id=cvjobcats.jobcat_id;

because there's no value to $r.
it also opens me up to allowing anyone to state *anything* after the  
?.

So can I make an else statement which will say that if there's no r=  
or  a wrong r= or even no ? at all then it should print a menu to  
$r's  which actually exist in the database? How?

Thanks in advance!!!
You have 3 conditions in a single expression. Split that expression up
Jackson got that bit from me - I don't think he is fully aware of what  
that
expression is doing!

the 'sum' of those conditions determines that either $r is 'good' or  
'bad'
(whether $r is garbage or not set didn't seem like a difference worth  
bothering
with)

No, I didn't and I actually still don't. I've implemented the change  
below, breaking up the if(isset)$_GET['r']) bit (making it easier to  
follow indeed, thank you!) but I am confused as to how to break that  
three-condition statement split based on that change.


into multiple expressions, so you can check each (or a combination of  
2) individually.
this is a good idea to better understand what is going on!
so, instead of:
if (isset($_GET['r'])  !empty($_GET['r'])  ($r =  
intval($_GET['r']))){
do:
if (isset($_GET['r'])) {
if(!empty($_GET['r'])  ($r = intval($_GET['r']))){
// do whatever
} else {
// something boring
}
} else {
// not set
}

The code below is where I am now.  I'm trying to document a bit better,  
and clean it up. And I still don't have any clue as to how to make it  
redirect if someone requests no ?r=  or a bad one. Can someone help  
please?

snip
if (isset($_GET['r'])) {
	if(!empty($_GET['r'])  ($r = intval($_GET['r']))){
  $fields = '*';
	  $where = WHERE cvjobcats.cv_id=cv.cv_id AND cvjobcats.jobcat_id =  
'$r' AND jobcat.jobcat_id=cvjobcats.jobcat_id;
  $sort = ORDER BY cv.sort; // Assemble the category items in  
r=x
	} else {
		// Is this where I'd say IF no $r is set then redirect?
	}
}

//Make the sql based on the joining of the table and intersection table
$sql = 
SELECT  
cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,jobcat 
.category
FROM cv, cvjobcats, jobcat
$where
$sort
;

$result = mysql_query($sql);
$cv = mysql_fetch_assoc($result);
$table_of_contents = array();
$result = mysql_query($sql);
if (!$result) {
  echo Could not successfully run query ($sql) from DB:  .  
mysql_error();
  exit;
}

if (mysql_num_rows($result) == 0) {
  echo No rows found, nothing to print so am exiting;
  exit;
}
/snip
Thanks in advance!!
--Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Fwd: [PHP] Newbie Question re substr

2005-03-08 Thread Jackson Linux
Thanks, Kim! Still having difficulties though..
On 8 Mar 2005, at 03:29, Kim Madsen wrote:

From: Jackson Linux [mailto:[EMAIL PROTECTED]
Sent: 8. marts 2005 04:23
First of all, echo the output to see if You get, what Tou expect in a 
debug situation:

if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0 200); // get first 200 
chars
// print and see if we get, what we expect
Print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
print lia href='{ . $_SERVER['PHP_SELF'] . 
}?a={$article_id}'}title='{$title}'{$article['title']}/abr 
/\n$content/li;
  }
}

echo 
 /ul;
I´ve put the  in front of title since the link otherwise would be 
a href=a=1234title=sometext, which is not what You want I guess.

And I substituted the
  $article['content'] = substr($article['content'], 0 200);/li; } }
with
  $content/li;
since I believe You want to print the content and not just assign it? 
Otherwise the br / makes no sense :-)

Can anyone help ?
I hop that did the trick for You :-)
It's really sensible and logical what you did. I really appreciate it.
1. $content = substr($article['content'], 0 200); // get first 200 
chars   is choking, and I've looked in docs and can't understand why. 
I get

Parse error: parse error, unexpected T_LNUMBER in 
/usr/www/users/domain/dynamic/templates/substr.htm on line 57

2.  This correction:
I´ve put the  in front of title since the link otherwise would be 
a href=a=1234title=sometext, which is not what You want I guess.
Wow. Actually I wanted it to make a href='a=1234' title='sometext' - 
does this:

print lia href='{ . $_SERVER['PHP_SELF'] . }?a={$article_id}'}' 
title='{$title}'{$article['title']}/abr /\n$content/li;

do that? (I ask because I can;t make any of it work?!)
Thanks so much for your help.


--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler
Naverland 31
DK-2600 Glostrup
www.comx.dk
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-

-
Nick Selby
Flyguides, Inc.
347 675 8295
http://www.flyguides.com/press/selby.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question re substr

2005-03-08 Thread Jackson Linux
On 8 Mar 2005, at 11:40, Richard Lynch wrote:
1. $content = substr($article['content'], 0 200); // get first  
200
chars   is choking, and I've looked in docs and can't understand why.
I get

Parse error: parse error, unexpected T_LNUMBER in
/usr/www/users/domain/dynamic/templates/substr.htm on line 57
In this line, PHP is somehow encountering a T_NUMBER (a number) where  
it
*expects* to see something else.

Like a comma.
Look between your 0 and 200 very carefully.

Thanks for taking the time. I had suspected that earlier, but when I  
put it in all sorts of OTHER stuff happened.

Then I saw your post and tried again. I saw that I had made another  
mistake later on. So you've solved that part - thanks!.

ExceptExcept it doesn't pull the content from the db and substr it  
to 200 characters. It pulls the id number and the title no problem, and  
I am sure that $article['content'] points to the right place (or at  
least it's named right) but it's just not getting the content:

if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0, 400); // get first 200  
chars
// print and see if we get, what we expect
// print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
$table_of_contents[] = lia  
href='{$_SERVER['PHP_SELF']}? 
a={$article_id}'}title='{$title}'{$article['title']}/abr/ 
$contentbr /a  
href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'  
title='{$article['title']}' ... [Read article]/a/li/li;
  }
}

echo 
 /ul;
Thanks in advance. . .
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re [PHP] Newbie Question re substr: Solved

2005-03-08 Thread Jackson Linux
Sorry if this posts twice. Thanks everyone for the help.
The missing comma was the problem with the display; the missing  
specification of the column at the start of the sql query was the  
problem with getting the data from the column.

Again, thanks all who replied for the fast and excellent help.
On 8 Mar 2005, at 11:40, Richard Lynch wrote:
1. $content = substr($article['content'], 0 200); // get first  
200
chars   is choking, and I've looked in docs and can't understand why.
I get

Parse error: parse error, unexpected T_LNUMBER in
/usr/www/users/domain/dynamic/templates/substr.htm on line 57
In this line, PHP is somehow encountering a T_NUMBER (a number) where  
it
*expects* to see something else.

Like a comma.
Look between your 0 and 200 very carefully.

Thanks for taking the time. I had suspected that earlier, but when I  
put it in all sorts of OTHER stuff happened.

Then I saw your post and tried again. I saw that I had made another  
mistake later on. So you've solved that part - thanks!.

ExceptExcept it doesn't pull the content from the db and substr it  
to 200 characters. It pulls the id number and the title no problem, and  
I am sure that $article['content'] points to the right place (or at  
least it's named right) but it's just not getting the content:

if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0, 400); // get first 200  
chars
// print and see if we get, what we expect
// print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
$table_of_contents[] = lia  
href='{$_SERVER['PHP_SELF']}? 
a={$article_id}'}title='{$title}'{$article['title']}/abr/ 
$contentbr /a  
href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'  
title='{$article['title']}' ... [Read article]/a/li/li;
  }
}

echo 
 /ul;
Thanks in advance. . .
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie LEFT JOIN question

2005-03-08 Thread Jackson Linux
Hi, all,
I have three tables; 'cv', the main table, 'jobcat', a definition table 
and 'cvjobcats',  an intersection table (for more detail see PS below).

I'd like to join this all together to be able to make a headline 
consisting of the plain English description of the job category 
followed by all rows within cv which contain a reference to that job 
category

I can follow this only to a point and that is where I ask for the 
List's help - does this even resemble the beginnings of what I want to 
accomplish? I've tried to comment as I go for my own sanity

//Select columns from 'cv', whose 'category' references numbers
//Select 'category' from 'jobcat' to translate the numbers to English
SELECT cv.cv_id,
cv.category,
dates,
cv.job_title,
cv.company,
cv.job,
    jobcat.category
FROM cv
LEFT JOIN cvjobcats
 ON cvjobcats.cv=cv.cv_id //Let tables cv and jobcat understand each 
other.

//This next bit I'm confused about
LEFT JOIN jobcat
 ON jobcat.jobcat_id=cvjobcats.jobcat
WHERE
 cvjobcats.jobcat='4';
Great. I'm now lost. Can anyone advise?
Thanks in advance,
PS:
 far too much information
cv contains columns including an primary key ('cv_id') and a column 
called 'category' which refers to job categories by number.

jobcat contains two fields: a primary key (jobcat_id) and a plain 
english description

cvjobcat contains two key columns: 'cv_id' and 'jobcat_id'.
/far too much information
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Question re substr

2005-03-07 Thread Jackson Linux
Hi,
I'm really new and getting lots of help but need some assistance.
I'm running a script which gets specific articles from a database if 
they're entered in the URL after the ? . For instance if someone asks 
for

www.foo.com/index.htm?a=1234
then the script would look for an database entry with the id of 1234 
and display it in the page.

If there's no number specified (www.foo.com/index.htm) or if the number 
given is to an article which doesn't exist, it gets the titles of all 
the articles available and prints them as links to the proper article 
number.

I'd also like it to grab the first 200 characters of text from the 
$content field of the entry.

With help I have the title link part and I suspect I'm close but I keep 
messing up the syntax

The code is:
snip
if (!empty($where)) {
echo 
 ul;
 $article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
 $table_of_contents[] = 
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}' 
title='{$article['title']}'{$article['title']}/abr /
$article['content'] = substr($article['content'], 0 200);/li;
}
}

echo 
 /ul;
/snip
Can anyone help ?
Thanks in advance!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question re substr

2005-03-07 Thread Jackson Linux
Zareef,
Almost
On 7 Mar 2005, at 23:52, Zareef Ahmed wrote:
From: [EMAIL PROTECTED]
Subject:Re: [PHP] Newbie Question re substr
Date:   7 March 2005 23:52:15 GMT-05:00
To:   [EMAIL PROTECTED]
Cc:   php-general@lists.php.net
Reply-To: [EMAIL PROTECTED]
On Mon, 7 Mar 2005 22:23:19 -0500, Jackson Linux
[EMAIL PROTECTED] wrote:
Hi,
I'm really new and getting lots of help but need some assistance.
I'm running a script which gets specific articles from a database if
they're entered in the URL after the ? . For instance if someone asks
for
www.foo.com/index.htm?a=1234
then the script would look for an database entry with the id of 1234
and display it in the page.
If there's no number specified (www.foo.com/index.htm) or if the number
given is to an article which doesn't exist, it gets the titles of all
the articles available and prints them as links to the proper article
number.
I'd also like it to grab the first 200 characters of text from the
$content field of the entry.
With help I have the title link part and I suspect I'm close but I keep
messing up the syntax
The code is:
snip
if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
  $table_of_contents[] = 
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'

title='{$article['title']}'{$article['title']}/abr /
$article['content'] = substr($article['content'], 0 200);/li;
change these two lines to
title='{$article['title']}'{$article['title']}/abr /.
substr($article['content'], 0, 200)./li;
zareef ahmed

I did that and now it reads this:

if (!empty($where)) {
echo 
 ul;
 $article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
 $table_of_contents[] = 
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
title='{$article['title']}'{$article['title']}/abr /.
substr($article['content'], 0, 200)./li;
}
}
\
Which doesn't kick back errors but also does not pull any 
$article['content'] - it leaves a line break but no text is being 
inserted from the content row.
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] I can't view files uploaded with PHP

2004-04-02 Thread Linux Zero
Hi everybody!

I write some PHP scripts for a system's module that allows the user to upload a file 
from his computer to the host. It works fine in a server with Linux   Apache   MySQL   
PHP (LAMP) environment. I based on the examples of this page:

http://www.php.net/manual/en/features.file-upload.php

Las week we transfer the whole system to another server with the same environment, but 
now the uploaded files can't be viewed in the browser. That's because the file is 
uploaded with 640 permissions and can't be opened by the browser with a wwwrun user.

We check in the old server and find that these uploaded files with 644 permissions. I 
check the httpd.conf and php.ini files looking for something like a umask option, but 
I find nothing like that.

Can anyone tell me what can I do to solve this problem in the new server? We can't 
return to the old server anymore!

Thanks a lot for your help!


http://www.latinmail.com - La forma más cómoda de enviar y recibir tus e-mails
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Web Hosts and PHP 4.10 +

2002-02-08 Thread linux

http://www.acilhost.com/en/index.php

Here you can find what you need.

They also offer custom solutions with the lowest prices in the
world...

On Fri, 08 Feb 2002 11:04:32 +, Neil Freeman wrote:
I have a feeling that www.aletia.com use 4.1.1

Edward Marczak wrote:

already takes advantage of this), I'd like to find a host
supporting 4.10
and MySQL.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] php static or dynamic?

2002-02-07 Thread linux

I have redhat 7.1, apache 1.3.22, php 4.1.1

I have installed php and other apache modules as static.

I have installed all php modules static.

I also installed java module as static (--with-java=..)

But I cannot enable java in php.ini
Also, lib_phpjava.so library is not created. Only lib_phpjava.a is
created.

Can I use both static and dynamic modules together?

How can I make lib_phpjava.so from lib_phpjava.a?

Thanks


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] phpinfo

2002-02-07 Thread linux


can I limit the information shown in phpinfo function?

the info it gives is a little risky for me

thanks


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php