|
An example.
1. Source code is a SQL schema or a file that represents a data model.
2. Perl code is used to generate the following
a. CRUD stored procedues.
b. DTO classes.
c. DAO classes.
To update one changes 1, then runs the script.
|
|
|
|
|
Hi im trying to get my calender to display on the website but it is showing errors such as this:
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'joeuser'@'localhost' (using password: YES) in C:\wamp\www\prog\addeventcal.php on line 8
Notice: Undefined variable: m in C:\wamp\www\prog\addeventcal.php on line 26 & 27 & 28
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\wamp\www\prog\addeventcal.php on line 29
here is my code. Can you please explain as to why it is not working. thank you
<html>
<head>
<title>Show/Add Events</title>
<head>
<body>
<h1>Show/Add Events</h1>
<?php
$mysqli = mysqli_connect("localhost", "joeuser", "YES", "testDB");
if($_POST){
$m = $_POST["m"];
$d = $_POST["d"];
$y = $_POST["y"];
$event_date = $y."-".$m."-".$d." ".$_POST["event_time_hh"].";
".$_POST["event_time_mm"].":00";
$insEVENT_sql = "INSERT INTO calender_events(event_title, event_shortdesc, event_start) VALUES('".$_POST["event_title"]."';
'".$_POST["event_shortdesc"]."', '$event_date')";
$insEvent_res = mysqli_query($mysqli, $insEvent_sql)
or die(mysqli_error($mysqli));
}
$getEvent_sql = "SELECT event_title, event_shortdesc,
date_format(event_start, '%l:%i %p') as fmt_date FROM
calender_events WHERE month(event_start) = '".$m."'
AND dayofmonth(event_start) = '".$d."' AND
year(event_start)= '".$y."' ORDER BY event_start";
$getEvent_res = mysqli_query($mysqli, $getEvent_sql)
or die(mysqli_error($mysqli));
if(mysqli_num_rows($getEvent_res) > 0){
$event_txt = "<ul>";
while($ev = @mysqli_fetch_array($getEvent_res)){
$event_title = stripslashes($ev["event_title"]);
$event_shortdesc = stripslashes($ev["event_desc"]);
$fmt_date = $ev["fmt_date"];
$event_txt .= "<li><strong>".$fmt_date."</strong>:
".$event_title."<br/>".$event_shortdesc."</li>";
}
$event_txt .= "</ul>";
mysqli_free_result($getEvent_res);
}else{
$event_txt = "";
}
mysqli_close($mysqli);
if($event_txt != ""){
echo "<p><strong>Today's Events:</strong></p>
$event_txt
<hr/>";
}
echo "
<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">
<p><strong>Would you like to add an event?</strong><br/>
Complete the form below and press the submit button to add
the event and refresh this window.</p>
<p><strong>Event Title:</strong><br/>
<input type=\"text\" name=\"event_title\" size=\"25\"
maxlenght=\"25\"/>
<p><strong>Event Discription:</strong><br/>
<input type=\"text\" name=\"event_desc\" size=\"25\"
maxlength=\"25\"/>
<p><strong>Event Time (hh:mm):</strong><br/>
<select name=\"event_time_hh\">";
for($x=1; $x <= 24; $x++){
echo "<option value=\"$x\">$x</option>";
}
echo "</select> :
<select name=\"event_time_mm\">
<option value=\"00\">00</option>
<option value=\"15\">15</option>
<option value=\"30\">30</option>
<option value=\"45\">45</option>
</select>
<input type=\"hidden\" name=\"m\" value=\"".$m."\">
<input type=\"hidden\" name=\"d\" value=\"".$d."\">
<input type=\"hidden\" name=\"y\" value=\"".$y."\">
<br/><br/>
<input type=\"submit\" name=\"submit\" value=\"Add Event\">
</form>";
?>
</body>
</html>
|
|
|
|
|
Your database connection is failing, which is causing some of your problems. Are you sure the password is "YES"? Does "joeuser"@"localhost" have permission to use the "testDB" database?
The "undefined variable" message is probably because you are using $m (and $d , $y ) to construct a query using them when they have not been defined. You are only defining them inside the if($_POST) { ... block, so if the page is loaded without POST data then they will be undefined.
|
|
|
|
|
o ok. that makes sense! i went back through my code and added in a $_GET to get the $m, $y, and $d. I also changed it from joeuser to root and password to "" since there wasnt a password set up. I found that I wasnt calling my database by the right in the connection call. Thank you for your help!
|
|
|
|
|
The problem is that your app[web page] doesn't create a successful database connection before passing you query statements to fetch data from the db::
//make sure you are using the correct user and password:
//if you are using any Apache servers like xampp,wampp.. and you never supplied your password later on ,then the default credentials to connect to your db is:====>
$host="localhost";
$user="root";
$password="";
$con = mysql_connect($host,$user,$password);
if(!$con){
echo "SERVER CONNECTION FAILED : source =".mysql_error();
exit; //remember this avoid any further page processing...
}
|
|
|
|
|
Hello again,
I'm trying to handle the language setting from the user. For that I've created a variable that I'm using in all the PHP files I have: $MyLangVar .
I would like to assign a default value to that variable to i.e. english.
So I've done this in my initialize file (a file that is being included by all the other files in the web site):
<?php
include($_SERVER['DOCUMENT_ROOT'].'/important_file_for_all.php');
if (!isset($GLOBALS['MyLangVar'])
{
$MyLangVar = "English";
}
?>
Both attempts have not worked properly IN THE 404.PHP PAGE.
At the beginning of each file I have this line: $MyLangVar = $GLOBALS['MyLangVar'];
How should I do this?
Thank you in advance.
[www.tamelectromecanica.com] Robots, CNC and PLC machines for grinding and polishing.
modified on Wednesday, March 30, 2011 2:16 PM
|
|
|
|
|
Where is the $MyLangVar declared? if it is inside the if statement it could be lost after the if statement is completed.
|
|
|
|
|
Hello Nick,
QUESTION PART:
This is something I've not understood properly:
if there is not a define, dim, type specification at the moment of declaring a variable, how one know where it has been declared?
Moreover if a web is not a structured setting of pages (I mean that one can access any page of the web without any specific order thanks to the search engines).
At the beginning of each file of the site I've got something like:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/file_that_must_be_included.php');
$MyLangVar = $GLOBALS['MyLangVar'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<h
<html>
<head>
Then, inside the "file_that_must_be_included.php" I've done this:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/another_global_file.php');
if (!isset($MyLangVar))
{
$MyLangVar = "English";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
Here it is where I'm trying to check if the variable has been initialized or not, and if it has not been initialized then I'm setting it to the default language.
CONCLUSIONS / IDEAS:
After writing the previous lines, I've thought:
* If declaring a variable inside a "if" clause makes it local, then having that "if (!isset..." it has no sense until the gloabal variable has been declared because just after leaving the if clause the var will be "destroyed".
* I guess I should change the line order in the main files: putting the "$MyLangVar = $GLOBALS['MyLangVar'];" line at the beginning, just before the "include($_SERVER['DOCUMENT_ROOT'].'/file_that_must_be_included.php');". In that way I've declared the $MyLangVar, it will become global for all the file (I guess, please confirm that) and therefore I'll only initialize it once (inside the sub_file "/file_that_must_be_included.php".
* I've tried that but in the 404.php file I can see a message telling me: Undefined index MyLangVar'...
Lost again...
Can you do something with all this data?
Thank you in advance!
|
|
|
|
|
If the variable is already declared it will stay global. Undefined index means that element of the array globals is not set.
The most useful function in php is var_dump()! It usually tells you what you need to know. I would var_dump( $GLOBALS ) and see what you get. feel free to contact me directly if you are still having dramas.
|
|
|
|
|
come to think of it $GLOBALS will not be storing the values once the pages when another page is loaded. What you want is
<?php session_start();
$_SESSION['MyLangVar'] = ??;
Then the variable will be stored between page loads.
|
|
|
|
|
You are my idol for today!
Thank you very much for your help!
$_SESSION has made it!
|
|
|
|
|
Joan, I'm curious, which PHP framework do you use?
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Now I'm using EasyPHP 5.3.5.0.
|
|
|
|
|
So I'm writing an index page that calls a header file within a different folder. The pages that seem to not work are the index pages WITHIN other folders and using ../ to get back to the root folder and back into the include folder, if the pages are within the root folder and call the header by going through the include folder, it works.
Kind of hard to explain..
But I'm getting these errors..
Warning: main(paul_menubar_test/menubar_test_filesavail.php) [function.main]: failed to open stream: No such file or directory in /home/new2/include/headers.php on line 190
Warning: main() [function.include]: Failed opening 'paul_menubar_test/menubar_test_filesavail.php' for inclusion (include_path='.:/usr/php4/lib/php') in /home/new2/include/headers.php on line 190
And that's an index file that's within a different folder in the root folder.
I have an index file in the root folder that does the call for the include/header and it works.
If you need any clarification, please ask.. I don't know how else to word it.
I've checked google and people just say "lol check ur pointers," I did, like a 100 times. I've tried all sorts of "/," "../" and all that. I've also read that I may need to change the permissions of the folder or something? I'm not sure how to do that.. but the other problem is every single page calls the FOOTER file, which is also in the "include folder," has no problem.
-Paul
|
|
|
|
|
lol, check your pointers!
just kidding
can you give an example of the file structure and explain how pages are called from one to the next? I have an idea you may have an issue related to your includes as it pertains to the current local directory and the use of relative paths.
Chris J
www.redash.org
|
|
|
|
|
if you include other files, the relative path back to root is from the first file.
so if page A is /A/index.php, which does a require_once('B/header.php') (in other words requires /A/B/header.php), then if /A/B/header.php wants to require_once /C/D/miniheader.php it needs to
require_once('../C/D/miniheader.php');
i.e. only one folder up (all the requires are relative to /A/index.php, the first script that ran)
|
|
|
|
|
if it is in the root of the site try
"{$_SERVER['DOCUMENT_ROOT]}/paul_menubar_test/menubar_test_filesavail.php";
|
|
|
|
|
hello
my work internet computer has been blocked by fortiguard web filter and i can't access half of the websites
i don't have admin user and i cant download any progrem including programming compailers
can someone help me please?
thanks in advenced
|
|
|
|
|
Do or do not, there is no "try"
|
|
|
|
|
|
|
How can I send variable to another form without include ?
|
|
|
|
|
Depends...is this second form on the same page or a different page?
Chris J
www.redash.org
|
|
|
|
|
|