RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3030 | Replies: 4 | Solved
Join Date: May 2006
Posts: 4
Reputation: Fel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Fel Fel is offline Offline
Newbie Poster

mysql errors, from submit.php and index.php

  #1  
May 28th, 2006
Hey, I've been trying to code my own news/ blogging script, by following a tutorial, but unfortunately I keep getting these mysql errors when I submit an entry, and on the page where I want it to be displayed. And I don't know how to recognize the errors just by looking at the number line, or how to fix it.

index.php
<?php 

//$hostname="placid1.placid-soul.org";
$user="xxx"; //user name to access database
$pass= "xxx"; //password 
$dbase="xxx"; //database name

$q = "select * from blog order by date desc "; 
$result= mysql_query($q, $connection) or die 
("Could not execute query : $q." . mysql_error()); 

// dynamic navigation variables 
$rows_per_page=1; // adjust the number here to display number of entries per page 
$total_records=mysql_num_rows($result); 
$pages = ceil($total_records / $rows_per_page); 

$screen = $_GET["screen"]; 
if (!isset($screen)) 
$screen=0; 
$start = $screen * $rows_per_page; 
$q .= "LIMIT $start, $rows_per_page"; 
$result= mysql_query($q, $connection) or die 
("Could not execute query : $q." . mysql_error()); 

while ($row=mysql_fetch_array($result)) 
{ 
    $id=$row["id"]; 
    $name=$row["name"]; 
    $email=$row["email"]; 
    $entry=$row["entry"]; 
    $date=$row["date"]; 
    $icon=$row["icon"]; 
    $title=$row["title"]; 

?> 

    <table width="345" border="0" cellspacing="1" cellpadding="0" class="updates"> 
    <tr> 
    <td><h1><?php echo "$title"; ?></h1></td> 
    </tr> 
    <tr> 
    <td> 
    <img src="<?php echo "$icon"; ?>" alt="icon" align="left"><?php echo "$entry"; ?>
    <p>Posted by <a href="mailto:<?php echo "$email"; ?>"><?php echo "$name"; ?> on <?php echo "$date"; ?>.</p> 
    </td> 
    </tr> 
    </table> 
     
    <div align="center"> 

<?php 
} #end of while 

// Display dynamic navigation here 

// create the dynamic links 
if ($screen > 0) { 
    $j = $screen - 1; 
    $url = "display.php?screen=$j"; 
    echo "<a href=\"$url\">Prev</a>"; 
} 

// page numbering links now 

for ($i = 0; $i < $pages; $i++) { 
    $url = "display.php?screen=" . $i; 
    $j = $i + 1; 
    echo " | <a href=\"$url\">$j</a> | "; 
} 

if ($screen < $pages-1) { 
    $j = $screen + 1; 
    $url = "display.php?screen=$j"; 
    echo "<a href=\"$url\">Next</a>"; 
} 

?> 

</div>

<?php include 'bottom.php'; ?>

submit.php
<?php //
$hostname="xxx";
$user="xxx"; //user name to access database
$pass= "xxx"; //password 
$dbase="xxx"; //database name
// For Global Registers off 

$name = strip_tags($_POST["name"]); 
$email = strip_tags($_POST["email"]); 
$entry = strip_tags($_POST["entry"]); 
$title = strip_tags($_POST["title"]); 
$icon =  strip_tags($_POST["icon"]); 

// Check if user submit blank entry 
if ($name == "" || $email == "" || $entry == "" || $title == "") 
{  
    die ("You must fill in all fields, please click back and try again."); 
} 

else { 
    $q="insert into blog (id,name,title,email,entry,date,icon) VALUES ('','$name','$title','$email','$entry',now(),'$icon')"; 
    $result = mysql_query($q); 
     
    if ($result)  
    { 
        echo "thank you, blog has been submitted."; 
    } 

}  
?>

And these are the errors:
index.php
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/.fiorello/felaigne/placid-soul.org/index.php on line 45
Could not execute query : select * from blog order by date desc .

submit.php
Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/.fiorello/felaigne/placid-soul.org/submit.php on line 22

Warning: mysql_query(): A link to the server could not be established in /home/.fiorello/felaigne/placid-soul.org/submit.php on line 22

I've tried looking through the search feature, and I couldn't find another thread with the same problem I have, so I thought I should create a new topic. I've tried my best to explain it, so that it's understandable at least. And if you need anymore information just let me know. =) Thank you, in advance.
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:45 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC