[php] Tutorial klopt niet?

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Momenteel probeer ik mijzelf php met sql aan te leren. Ik volg daartoe een tutirial:
http://www.devshed.com/c/...ilding-a-Product-Catalog/

In deze tutorial gebruikt men een initialize.php welke tekens wordt include.

------------------------------------------------------------------------------------------------
/* turn on verbose error reporting (15) to see all warnings and errors */
error_reporting(15);

/* define a generic object */
class object {};

/* setup the configuration object */
$CFG = new object;

$CFG->dbhost = "localhost";
$CFG->dbname = "mymarket";
$CFG->dbuser = "myuser";
$CFG->dbpass = "mypassword";

$CFG->wwwroot = "/mymarket";
$CFG->dirroot = "/home/httpd/html/mymarket";
$CFG->templatedir = "$CFG->dirroot/templates";
$CFG->libdir = "$CFG->dirroot/lib";
$CFG->imagedir = "$CFG->wwwroot/images";

/* define database error handling behavior, since we are in development stages
* we will turn on all the debugging messages to help us troubleshoot */
$DB_DEBUG = true;
$DB_DIE_ON_FAIL = true;

/* load up standard libraries */
require("$CFG->libdir/stdlib.php");
require("$CFG->libdir/dblib.php");

/* setup some global variables */
$ME = $SCRIPT_NAME;

/* connect to the database */
db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass);
?>

------------------------------------------------------------------------------------------------


Nu loop ik vast tijdens het browsen doordat de $ME = $SCRIPT_NAME; waarschijnlijk niet goed is?!

Deze functie wordt aangeroepen:
------------------------------------------------------------------------------------------------
function print_add_category_form($id) {
/* print a blank category form so we can add a new category */

global $CFG, $ME;

/* get the name of the parent category */
$qid = db_query("SELECT name AS parent FROM categories WHERE id = $id");
$frm = db_fetch_array($qid);

/* set default values for the reset of the fields */
$frm["parent"] = ov($frm["parent"]);
$frm["newmode"] = "insert";
$frm["name"] = "";
$frm["description"] = "";
$frm["submit_caption"] = "Add Subcategory";

include("templates/category_form.php");
}
------------------------------------------------------------------------------------------------


Hieronder staat de "templates/category_form.php"
------------------------------------------------------------------------------------------------

<form name="entryform" method="post" action="<?=$ME?>">
<input type="hidden" name="mode" value="<?=$frm["newmode"]?>">
<input type="hidden" name="id" value="<?=pv($id)?>">
<table>
<tr>
<td class=label>Parent:</td>
<td class=normal><?=$frm["parent"]?></td>
</tr>
<tr>
<td class=label>Name:</td>
<td><input type="text" name="name" size=25 value="<? pv($frm["name"]) ?>"></td>
</tr>
<tr valign=top>
<td class=label>Description:</td>
<td><textarea name="description" cols=50 rows=5><? pv($frm["description"]) ?></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="<?=$frm["submit_caption"] ?>"></td>
</table>
</form>

Er gebeurd vervolgens niets.... ik verwacht een formulier.
---------------------------------------------------------------------------------------------------------

:'(

Acties:
  • 0 Henk 'm!

  • PrisonerOfPain
  • Registratie: Januari 2003
  • Laatst online: 26-05 17:08
$_SERVER['SCRIPT_NAME'] gebruiken?

Acties:
  • 0 Henk 'm!

  • PowerSp00n
  • Registratie: Februari 2002
  • Laatst online: 19-08 08:24

PowerSp00n

There is no spoon

FAQ? Jouw probleem heeft met hetzelfde FAQ item te maken.

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Dan kom ik wel verder dan ooit maar krijg het volgende te zien:

--------------------------------------------------------------------
Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.

For more information as to why this behaviour exists, see the manual page for CGI security.

For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.
--------------------------------------------------------------------

Acties:
  • 0 Henk 'm!

Verwijderd

ff vitten op de code:
PHP:
1
2
/* turn on verbose error reporting (15) to see all warnings and errors */
error_reporting(15);


het is beter gebruik te maken van gedefinieerde constanten zoals E_ALL en dergelijke, omdat die integer values wel eens kunnen veranderen

http://be2.php.net/manual/nl/function.error-reporting.php

Acties:
  • 0 Henk 'm!

  • PrisonerOfPain
  • Registratie: Januari 2003
  • Laatst online: 26-05 17:08
Verwijderd schreef op 29 oktober 2004 @ 17:58:
ff vitten op de code:
PHP:
1
2
/* turn on verbose error reporting (15) to see all warnings and errors */
error_reporting(15);


het is beter gebruik te maken van gedefinieerde constanten zoals E_ALL en dergelijke, omdat die integer values wel eens kunnen veranderen

http://be2.php.net/manual/nl/function.error-reporting.php
Daarbij word die regel commentaar dan ook in een klap overbodig, omdat niemand weet dat die 15 inhoud, maar E_ALL geeft meteen een betekenis aan de waarde.
Pagina: 1