php

PHP - php.net

How do I alter a date field to insert the current date

I have a mysql table that every time I insert to I have to pass the date. How can I alter the table to auto insert the current date.

I'm using php but can alter the table straight through mysql.

in

How to reuse the same query on the page

I have added my first php page to add a dynamic page but need to display the results of a my sql query in different sections.

For a menu to link to its own page and display a summary of each seperatly on the page.

<?php
$query
= mysql_query("SELECT * FROM descriptions");
while (
$row=mysql_fetch_array($query)){
  print
'<a href='more.php?id=' . $row['id'] . '">' . $row['name'] . '</a><br />';
}

?>

PHP date questions (GetYear,GetMonth,GetDay)?

Does PHP have functions for GetYear, GetMonth, & GetDay

example:
$Date = 2009-8-7;
$Year = GetYear($Date);
print $Year;//print 2009
and so on . . .

I know there are mysql results but nevery any in php

I have a query that never returns any results or errors. When I run the sql directly through phpmyadmin the results come back fine.

just trying to dump row right now to see whats coming back

<?php
$link
= mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!
$link) {
    die(
'Could not connect: ' . mysql_error());
}

$sql = "SELECT ProductID,Name FROM products WHERE ProductID > 5 ORDER BY ProductID DESC";
$query = mysql_query($sql);
while (
$row = mysql_fetch_object($query)){
var_dump($row);
}
?>

Warning: session_start() [function.session-start]: Cannot send session cookie

I'm just starting php and test page was working but now getting
Warning: session_start() [function.session-start]: Cannot send session cookie

I just made some minor edits and now its not working.

How do I stop double posts in php

I'm helping someone with an old someone else made admin program to add / edit / delete records

Some of the people working on it are always pressing the back and forward button and reposting the info multiple times. Is there a way keep this from happening?

not the real code but close enough

<form method="post" action="addrecord.php">
<input type="text" name="title" />
..
..
..
<input type="submit" value="Add Record" />
</form>

The addrecord.php page

<?
include_once('dataconnection.php');
$title=$_POST['title'];
more fields
.
.
.

Query results into an array only storing one result

I'm successfully connecting to a mssql database and getting results, but I'm trying to place them in an array for display on the page.

The following always gets 1 result and nothing more.
I thought arrays are supposed to store multiple results?

<?php

$conn=odbc_connect('*****','******','*****');
if (!$conn)
{exit("Connection Failed: " . $conn);}

$sql="select Name,Id,Group from members";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");
echo '';

while (odbc_fetch_row($rs))
{
$id=odbc_result($rs,"Id");

How turn one variable into two in PHP

I have a form that only has one field for name and I want to get the two values submitted and store first and last as seperate values in the database. How would I do that?

<?php
$name
= $_POST['name'];
...
?>

Adding an editable area to drupal

I have a theme thats working great but I want to add a new block region so I can edit an area from within the admin / not having to open template files to alter.

How can I find out and fix this error in Drupal - Call to undefined function views_build_view()

Whenever I run cron.php it hangs with the error

Fatal error: Call to undefined function views_build_view() in path-to-my-install/includes/common.inc(1537) : eval()'d code on line 3

The site has been up for some time but has multiple admin / authors and no one knows what happened.

How can I narrow down what could be causing this I've looked through tons of files and even raw database fields but still nothing that I can see would be causing this.

Syndicate content