Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 27th, 2003, 09:49 AM
mmlug mmlug is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 4 mmlug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem With mysql!

Dear all,
I have a big problem with my PHP news scripts.
I got the following error...
Please help me...

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
My PHP versionHP Version 4.3.3RC2-dev
Mysql : MySQL 4.0.14
php Code:
Original - php Code
  1.  
  2. <?php
  3. include"config.php";
  4. $db = mysql_connect($db_host,$db_user,$db_pass);
  5.  
  6. //$id=1; //$_GET[id];
  7. //print_r($_GET);
  8.  
  9. $id=$_GET[id];
  10.  
  11. $query="SELECT title,news FROM news WHERE id=$id";
  12. //echo "<br>$query";
  13.  
  14. $result=mysql_query($query)or die(mysql_error());
  15.        while($rows= mysql_fetch_array($result))
  16.         {
  17.             $title=$rows["title"];
  18.             $news=$rows["new"];
  19.   echo "<form name="edit_process.php" method="post"> action="edit_save.php?id=$id">
  20.  
  21.   <p>Title :
  22.     <input type="text" name="title" value="$title">
  23.   </p>
  24.   <p>News :</p>
  25.   <p>
  26.     <textarea name="news" cols="40" rows="6">$news</textarea>
  27.   </p>
  28.   <p>
  29.     <input type="submit" name="Submit" value="Save">
  30.   </p>
  31. </form>";
  32. }
  33.  
  34. ?>


Best regards,
mmlug

Reply With Quote
  #2  
Old September 27th, 2003, 12:02 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
RE: Problem With mysql!

if you uncomment the line that says

echo "<br>$query";

and run the script, what is the the query that is output?

Reply With Quote
  #3  
Old September 27th, 2003, 12:08 PM
CodeKadiya CodeKadiya is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,330 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 50 m 36 sec
Reputation Power: 5
Send a message via Yahoo to CodeKadiya
RE: Problem With mysql!

Try and use your SQL query like this.

$query="SELECT title,news FROM news WHERE id='$id'";

Is this working????

Reply With Quote
  #4  
Old September 28th, 2003, 02:29 AM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Problem With mysql!

Try this on the second line...

replace
include"config.php";
with this
include("config.php");

Reply With Quote
  #5  
Old September 28th, 2003, 07:51 AM
mmlug mmlug is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 4 mmlug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: RE: Problem With mysql!

Quote:
if you uncomment the line that says

php Code:
Original - php Code
  1. echo "<br>$query";

and run the script, what is the the query that is output?


Yes, I got this error message ..
Code:
SELECT title,news FROM news WHERE id= You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

best reagards,
MMlug

Reply With Quote
  #6  
Old September 28th, 2003, 07:57 AM
Ashkhan Ashkhan is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 372 Ashkhan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 57 sec
Reputation Power: 3
RE: Problem With mysql!

It seems that value of $_GET['id'] is not set. Do you get it from a form or from url?

Reply With Quote
  #7  
Old September 28th, 2003, 08:13 AM
mmlug mmlug is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 4 mmlug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Problem With mysql!

Yes I hvae one form to post my news to myssql database. Could be here something wrong?
php Code:
Original - php Code
  1.  
  2. <form name="post news" method="post" action="postnews.php">
  3.   <p>Title : <input type="text" name="title">
  4.   <br>
  5.   Author : <input type="text" name="author">
  6.     <br>
  7.     News :
  8.     <br>
  9.     <textarea name="news" cols="40" rows="6"></textarea></p>
  10.   <p><input type="submit" name="Submit" value="POST !"></p>
  11.   </form>

postnews.php is like here : :
php Code:
Original - php Code
  1.  
  2. <?php
  3. include "config.php";
  4.  
  5. $db = mysql_connect($db_host,$db_user,$db_pass);
  6. mysql_select_db("$db_name") or  die(mysql_error());
  7. $title=$_POST[title];
  8. $news=$_POST[news];
  9. $author=$_POST[author];
  10. $query = "INSERT INTO news (title,news,author,date)VALUES('$title','$news','$  author',now())";
  11. mysql_query($query);
  12. echo "News item entered.";
  13. ?>


My view.php is like here
php Code:
Original - php Code
  1.  
  2.  
  3. $query ="SELECT title, news, author, date FROM news ORDER by id DESC LIMIT 5";
  4.     $result = mysql_query($query);
  5.     while($rows = mysql_fetch_array($result))
  6.         {
  7.             $title = $rows["title"];
  8.             $news =$rows["news"];
  9.             $author=$rows["author"];
  10.             $date =$rows["date"];
  11. echo "<TABLE><TR><TD>$title</TD></TR>
  12. <TR><TD>$news</TD></TR><TR><TD>$author</TD></TR>
  13. <TR><TD>Posted by $author on $date</TD></TR>   
  14. </TABLE>";
  15.            
  16. }
  17. ?>

best reagrds,
mmlug

Reply With Quote
  #8  
Old September 28th, 2003, 08:29 AM
Ashkhan Ashkhan is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 372 Ashkhan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 57 sec
Reputation Power: 3
RE: Problem With mysql!

Your problem lies in your form method.
The method is post, so that your $id variable will be stored in $_POST['id'] and not in $_GET['id'].

btw: I don't see any element with id name in your form. You are not setting it at all!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Problem With mysql!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek