Jump to content

Recommended Posts

Hi guys,

 

back again so soon, sorry.

 

but i'm getting an error code from this piece for script that i don't understand: Undefined offset: 2

 

and : Undefined offset: 1

 

am i not doing this correctly...?

 

<?php
include("whatever.php");

mysql_connect($host, $db, $pass)
or die ("Could not connect to mysql because ".mysql_error());

mysql_select_db($db)
or die ("Could not select database because ".mysql_error());

$mysite_username = $HTTP_COOKIE_VARS["sitename"]; 

$year=mysql_query("SELECT dob FROM $table WHERE username = '$mysite_username'");
while($year1 = mysql_fetch_array($year))
$year1['dob']; 

list ($y, $sm, $d) = explode ('-', $year1);

echo number_format($d);

?>

 

Thanks for all your help,

$year = mysql_query("SELECT dob FROM $table WHERE username = '$mysite_username'");
$year1 = mysql_fetch_array($year);
$dob = $year1['dob']; // this line is revised
list ($y, $sm, $d) = explode ('-', $dob); // slight change
echo number_format($d);

 

I assume it's a single result, so no while needed.

 

Hi Andy,

 

Thanks for the reply

 

I got it going like this, which i assume works, but now it's only single digits,

 

e.g: 0 instead of 00

 

is there a way to make number_format double digits..?

 

Thanks

 

<?php
$year=mysql_query("SELECT dob FROM $table WHERE username = '$mysite_username'");
while($year1 = mysql_fetch_array($year))
echo $year1['dob']; 

echo number_format(date($year1,"dd"));

?>

Here's the answer.

 

include("whatever.php");

mysql_connect($host, $db, $pass)
or die ("Could not connect to mysql because ".mysql_error());

mysql_select_db($db)
or die ("Could not select database because ".mysql_error());

$mysite_username = $HTTP_COOKIE_VARS["sitename"]; 

$year=mysql_query("SELECT dob FROM `profile` WHERE username = '$mysite_username'");
while($year1 = mysql_fetch_array($year))
$test = $year1['dob'];

list($a, $v, $c) = explode('-',$test);

echo $c

 

yipee!

 

i solved one :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.