Search
Left Quote    I start where the last man left off.
- Thomas A. Edison    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: News System
  This user is offline  alex1985
  Subject: "News System" Posted: @ 3:34 pm on Apr 17 2008   
Member #: 668
Rank: User - (6)
Since: 04/17/08
Posts: 6

You did write the News System, that's a really good tutorial! Can you provide with another tutorial concerning News System.

I just wanna have kind of abstract or small description of the news, then, there will be a button called read more, for instance, when it got clicked it will lead to the full story of the news.

Best Regards.


    Viewed: 17,521 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: News System" Posted: @ 8:37 pm on Apr 17 2008    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Alex,

sm0ke is the author of the News article. The answer to your question can easily be achieved. If you have a table that stores your news, add a column for 'abstract' or something. Then, simply display the abstract with a "read more" link/button at the end that takes you to the body of the news.




-bs0d | AllSyntax.com

    Viewed: 17,510 Times | Reply to This | To top
  This user is offline  alex1985
  Subject: "re: News System" Posted: @ 10:33 pm on Apr 18 2008    
Member #: 668
Rank: User - (6)
Since: 04/17/08
Posts: 6

  bs0d said...

< i> Alex,

sm0ke is the author of the News article. The answer to your question can easily be achieved. If you have a table that stores your news, add a column for 'abstract' or something. Then, simply display the abstract with a "read more" link/button at the end that takes you to the body of the news.


I'm asking for the tutorial as well, because I'm novice in PHP Programming.




    Viewed: 17,489 Times | Reply to This | To top
  This user is offline  alex1985
  Subject: "re: News System" Posted: @ 3:13 pm on Apr 20 2008    
Member #: 668
Rank: User - (6)
Since: 04/17/08
Posts: 6

I got the mistake while doing that PHP tutorial:

This is the code itself:


Code:


<?
//Set the database values
$confg['db_una me']="al ex1985_admin&q uot; //Your database username
$confg['db_pas wd']="05 05009127" //Your database user's password
$confg['db_hos t']="loc alhost" //Your host
$confg['db_dba se']="bo oks" //Your database name
//Create the function to log into the DB
function db_login() {
global $confg;
$link = @mysql_connect( $confg['db_hos t'], $confg['db_una me'], $confg['db_pas wd']) or die("Erro r connecting: " . mysql_error());
@mysql_select_d b($confg['db_d base'], $link);
}
//Create the function for logging out from the DB
function db_logout() {
@mysql_close($l ink);
}
?>



But, this is the message the browser gives me when I am trying to initiate that constructed file.

[quote]
"Parse error: syntax error, unexpected T_VARIABLE in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/config.php on line 4"
[/quote]

If I am not mistaken there is the mistake with the entry: "$confg[ 'db_paswd']=& quot;userpw&qu ot;, for instance.

I'm sure that I entered it correctly.

What should I do?



Edited at 05:12:26 pm on 04/21/08

    Viewed: 17,469 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: News System" Posted: @ 4:07 pm on Apr 20 2008    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

I think you forgot to put ; at the end. Try this:

Code:

<?php
//Set the database values
$confg['db_una me']="al ex1985_admin&q uot;; //Your database username
$confg['db_pas wd']="05 05009127" ; //Your database user's password
$confg['db_hos t']="loc alhost"; //Your host
$confg['db_dba se']="bo oks"; //Your database name
//Create the function to log into the DB
function db_login() {
global $confg;
$link = @mysql_connect( $confg['db_hos t'], $confg['db_una me'], $confg['db_pas wd']) or die("Erro r connecting: " . mysql_error());
@mysql_select_d b($confg['db_d base'], $link);
}
//Create the function for logging out from the DB
function db_logout() {
@mysql_close($l ink);
}
?>




    Viewed: 17,462 Times | Reply to This | To top
  This user is offline  alex1985
  Subject: "re: News System" Posted: @ 7:31 am on Apr 21 2008    
Member #: 668
Rank: User - (6)
Since: 04/17/08
Posts: 6

Thanks. I did really forgot to put ";" .

But there are the following mistakes:


Code:

Warning: require_once() [function.requi re-once]: open_basedir restriction in effect. File(/mulhim.ou tlaw.trap17.com /library_projec t/test_dir/test 1/config.php) is not within the allowed path(s): (/home/alex1985 /:/usr/lib/php: /usr/local/lib/ php:/tmp) in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/admin/add. php on line 2

Warning: require_once(/m ulhim.outlaw.tr ap17.com/librar y_project/test_ dir/test1/confi g.php) [function.requi re-once]: failed to open stream: Operation not permitted in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/admin/add. php on line 2

Fatal error: require_once() [function.requi re]: Failed opening required '/mulhim.outla w.trap17.com/li brary_project/t est_dir/test1/c onfig.php' (include_path= '.:/usr/lib/php :/usr/local/lib /php') in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/admin/add. php on line 2/code]

Your instance for location of file do not work properly.




    Viewed: 17,447 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: News System" Posted: @ 1:40 pm on Apr 21 2008    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

looks like you're specifying the path incorrectly to require_once. it doesn't look like you've posted that line of code, but the path should start with '/home/alex198 5/' since that's likely the only place you're allowed to store files. note that the error message says that your add.php script is in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/admin/ -- i'm not sure where that puts the config.php file you're trying to require, but i suspect it's /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/config.php




please note that the above post is likely made up in its entirety.

    Viewed: 17,437 Times | Reply to This | To top
  This user is offline  alex1985
  Subject: "re: News System" Posted: @ 2:19 pm on Apr 21 2008    
Member #: 668
Rank: User - (6)
Since: 04/17/08
Posts: 6

It happens again.


Code:

Warning: require_once(ho me/alex1985/pub lic_html/mulhim /library_projec t/test_dir/test 1/config.php) [function.requi re-once]: failed to open stream: No such file or directory in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/admin/add. php on line 2

Fatal error: require_once() [function.requi re]: Failed opening required 'home/alex1985 /public_html/mu lhim/library_pr oject/test_dir/ test1/config.ph p' (include_path= '.:/usr/lib/php :/usr/local/lib /php') in /home/alex1985/ public_html/mul him/library_pro ject/test_dir/t est1/admin/add. php on line 2




    Viewed: 17,433 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: News System" Posted: @ 1:58 pm on Apr 22 2008    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

looks like you left off the slash in front of home.




please note that the above post is likely made up in its entirety.

    Viewed: 17,412 Times | Reply to This | To top
  This user is offline  alex1985
  Subject: "re: News System" Posted: @ 5:09 am on Apr 23 2008    
Member #: 668
Rank: User - (6)
Since: 04/17/08
Posts: 6

The form "add.php " appears on the screen, but it does not work, like it does not update the database, why?

 name_h ere said...[< ;?

//Setting the database values

$confg['db_una me'] = "alex1985 _admin"; //Your database username
$confg['db_pas wd'] = "05050091 27"; //Your database password
$confg['db_hos t'] = "localhos t"; //Your host, frequently localhost is used
$confg['db_dba se'] = "alex1985 _books"; //Your database name

//Creating the function to log into the DB

function db_login() {
global $confg;
$link = @mysql_connect( $confg['db_hos t'], $confg['db_una me'], $confg['db_pas wd']) or die("Erro r connecting: " . mysql_error());
@mysql_select_d b($confg['db_d base'], $link);
}

//Creating the function for logging out from the DB

function db_logout() {
@mysql_close($l ink);
}
?>]

 name_h ere said...[< ;?
require_once ("../conf ig.php";//Cal ling the configuration file of the system

//Form was not yet submitted
//Display initial form

if (!$submit)
{
?>

<html>
Add New Post<br />
<form action="& lt;? echo $PHP_SELF; ?>" method="p ost">< br /> <input type="hid den" name="id " value="id ">
Title:<br />
<input size="50 " maxlength=&quo t;60" type="tex t" name="tit le">&l t;br />
Book Content<br />
<textarea name="con tent" cols="40 " rows="10 "></ textarea>< ;br />
Authors:<br />
<input size="50 " maxlength=&quo t;250" type="tex t" name="aut hors"> <br />
<input type="sub mit" name="sub mit" value="up date"> <br />
</form>
<?
} else {

//Setting up the error array

$err=array(); $count=0;

//Validating the user text input fields

if (!$title) { $err[$count]=& quot;Invalid Entry: Title"; $count++; }
if (!$content) { $err[$count]=& quot;Invalid Entry: Book's Content";
$count++; }
if (!$authors) { $err[$count]=& quot;Invalid Entry: Authors";
$count++; }

//If no errors were found, then===>

if (sizeof($err)== 0) {
db_login(); //The function which is created in the configuration file of the system

//Generating and executing query to insert the typed data

$query = "INSERT INTO alex1985_books( id, title, content, author, date) VALUES(0, '$title', '$content', '$author', NOW())";
$result=mysql_q uery($query) or die("Erro r in query: $query.". mysql_error());

// Printing results

echo "Update successful. <a href='index.ph p'>Go back to the main menu</a>. ";
} else {

// Errors are found, printing them as a list

echo "<font size=-1>The following errors were encountered: <br>&quo t;;
echo "<ul&g t;";
for ($x=0; $x<sizeof($e rrorList); $x++) {
echo "<li&g t;$errorList[$x ]";
}
echo "</ul& gt;</font> ;";
}
}
?>]




    Viewed: 17,403 Times | Reply to This | To top
  This user is offline  s141797
  Subject: "re: News System" Posted: @ 10:54 am on Nov 16 2008    
Member #: 785
Rank: User - (1)
Since: 11/16/08
Posts: 1

Im having the same problem...
It look like:
if (!$submit) is true everytime, even
when i hit the submit button...




    Viewed: 15,307 Times | Reply to This | To top
  This user is offline  Genius
  Subject: "re: News System" Posted: @ 1:47 pm on Nov 20 2008    

Member #: 582
Rank: User - (77)
Since: 02/18/08
Posts: 76
From: kmmk

I think you got problem here:


Code:

$query = "INSERT INTO alex1985_books( id, title, content, author, date) VALUES(0, '$title', '$content', '$author', NOW())";< /div>


You are making every news to have 0 id number? Fix the values of ID to variable id not the number.




    Viewed: 15,253 Times | Reply to This | To top
  This user is offline  David1159
  Subject: "re: News System" Posted: @ 7:38 pm on Nov 21 2008    

Member #: 526
Rank: User - (81)
Since: 12/27/07
Posts: 81
From: usa

Your submit is true every time because you can't use if(!$submit)

Try-

if(!$_POST['su bmit'])




Coding is simply CST... Combining $hit Together. We make different $hit to run in unison correctly.

    Viewed: 15,231 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank