הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   [PHP] מה הבעיה בקוד הבא ? (https://hosts.co.il/forums/showthread.php?t=44351)

Gold-System 26-04-07 19:51

[PHP] מה הבעיה בקוד הבא ?
 
PHP קוד:

<?
include "config.php"
if ( 
$_POST["xds"] != "1" ) {
$query mysql_query("SELECT * FROM `msg`"); 
$con mysql_fetch_array($query);
$msg $con['Update'];

echo <<<EOF
<html> 
<head>
<form action="messege.php" method="POST"> 
<div align="center"> 
<textarea name="messege">
{$msg}</textarea> 
<input type="hidden" value="1" name="xds" />
<input type="submit" value="עדכן תיבה">
</form> 
</html>
EOF;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE `msg` SET Update = '{$update}'");
}
?>

לא שומר את הנתונים בתיבה,
תודה |winky|

WebProject 26-04-07 19:59

אממ נסה להוריד את הסוגריים המסולסלים מן המשתנה $msg

Gold-System 26-04-07 20:11

הוצאתי, לא עובד,
הנה, תראה -
http://goldsystem.co.il/Panel/messege.php

Eran-s 26-04-07 20:53

תדפיס אותו עם echo רגיל לבדוק בכלל אם יש בו תוכן

Gold-System 26-04-07 20:56

איך?

Eran-s 26-04-07 20:58

ציטוט:

נכתב במקור על ידי Gold-System (פרסם 466752)
איך?

echo לפני ה-EOF?

Gold-System 26-04-07 21:00

ציטוט:

נכתב במקור על ידי Eran-s (פרסם 466753)
echo לפני ה-EOF?

אז להוציא את ה echo ?

BlueNosE 26-04-07 21:03

UPDATE זו מילה שמורה. אתה לא יכול לקרוא לשדה בשם הזה.

WebProject 26-04-07 21:04

ציטוט:

נכתב במקור על ידי BlueNosE (פרסם 466761)
UPDATE זו מילה שמורה. אתה לא יכול לקרוא לשדה בשם הזה.

צודק, אם הוא היה שם or died( mysql_error()); הוא היה מקבל שגיאת syntax :)

Gold-System 26-04-07 21:06

אז לשנות את האפדייט לשם אחר לשדה ב PhpMyAdmin?
*****

שיניתי את השם ל Updote ולא עובד..
הנה הקוד -
PHP קוד:

<?
include "config.php"
if ( 
$_POST["xds"] != "1" ) {
$query mysql_query("SELECT * FROM `msg`"); 
$con mysql_fetch_array($query);
$msg $con['Update'];

echo <<<EOF
<html> 
<head>
<form action="messege.php" method="POST"> 
<div align="center"> 
<textarea name="messege">$msg</textarea> 
<input type="hidden" value="1" name="xds" />
<input type="submit" value="עדכן תיבה">
</form> 
</html>
EOF;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE `msg` SET Updote = '{$update}'");
}
?>


Rom 26-04-07 21:13

תשנה גם פה לUpdote
$msg = $con['Update'];

Gold-System 26-04-07 21:16

אה, נכון חח שכחתי ..
אבל עדיין לא עובד -
PHP קוד:

<?
include "config.php"
if ( 
$_POST["xds"] != "1" ) {
$query mysql_query("SELECT * FROM `msg`"); 
$con mysql_fetch_array($query);
$msg $con['Updote'];

echo <<<EOF
<html> 
<head>
<form action="messege.php" method="POST"> 
<div align="center"> 
<textarea name="messege">
{$msg}</textarea> 
<input type="hidden" value="1" name="xds" />
<input type="submit" value="עדכן תיבה">
</form> 
</html>
EOF;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE `msg` SET Updote = '{$update}'");
}
?>


Tomer 26-04-07 21:19

echo $msg - מציג את ההודעה?

Gold-System 26-04-07 21:21

מציג רק את ההודעה עם אני לוחץ על "הקודם" לאחר שאני כותב משהו ולוחץ על "שלח", זה מציג דף לבן, אז אני עושה "הקודם" וזה מציג את מה שכתבתי, אבל אם אני מרענן \ יוצא ונכנס מהדף - שוב התיבה ריקה..

4ior 26-04-07 21:26

הבעיה היא ש$msg
הוא מערך. אתה צריך להגביל אותו ל1
שים LIMIT 1 בquery

Rom 26-04-07 21:28

ציטוט:

נכתב במקור על ידי 4ior (פרסם 466803)
הבעיה היא ש$msg
הוא מערך. אתה צריך להגביל אותו ל1
שים LIMIT 1 בquery

אה?!
msg לא מערך

Gold-System 26-04-07 21:28

ככה?
PHP קוד:

$query mysql_query("SELECT * FROM `msg` LIMIT 1"); 


Tomer 26-04-07 21:29

ציטוט:

נכתב במקור על ידי 4ior (פרסם 466803)
הבעיה היא ש$msg
הוא מערך. אתה צריך להגביל אותו ל1
שים LIMIT 1 בquery

מה שהוא עשה זה בסדר,
PHP קוד:

$query mysql_query("SELECT * FROM `msg`");  
$con mysql_fetch_array($query); 
$msg $con['Updote']; 

הוא שולף הכל מ msg, עושה לזה fetch (בלי לולאה - ייקח רק אחד), ומכניס ל $msg את השדה Updote

Rom 26-04-07 21:30

תנסה להוריד את הסוגריים המסולסלים מהשורה:
mysql_query("UPDATE `msg` SET Updote = '{$update}'");

אני לא בטוח שזה יעזור אבל תמיד אפשר לנסות D:

Gold-System 26-04-07 21:31

אז למה לעזעאזל זה לא עובד?
אתם לא מבינים?

****

עשיתי כך ולא עובד -
PHP קוד:

<?
include "config.php"
if ( 
$_POST["xds"] != "1" ) {
$query mysql_query("SELECT * FROM `msg` LIMIT 1"); 
$con mysql_fetch_array($query);
$msg $con['Updote'];

echo <<<EOF
<html> 
<head>
<form action="messege.php" method="POST"> 
<div align="center"> 
<textarea name="messege">
{$msg}</textarea> 
<input type="hidden" value="1" name="xds" />
<input type="submit" value="עדכן תיבה">
</form> 
</html>
EOF;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE `msg` SET Updote = '$update'");
}
?>

ניסיתי להוציא גם ה "{ }" מה $msg ולא עוזר..

4ior 26-04-07 21:38

תשנה את זה רגע לזה:
PHP קוד:

<?
include "config.php"
if ( !isset(
$_POST['messege']) ) {
$query mysql_query("SELECT * FROM `msg` LIMIT `1`") or die(mysql_error()); 
$con mysql_fetch_object($query);
$msg $con->Updote;
echo 
"
<html> 
<head>
<form action='messege.php' method='POST'> 
<div align='center'> 
<textarea name='messege'>$msg</textarea> 
<input type='hidden' value='1' name='xds' />
<input type='submit' value='עדכן תיבה'>
</form> 
</html>
"
;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE `msg` SET Updote = '$update'") or die(mysql_error());
}
?>


Gold-System 26-04-07 21:43

שיניתי,

שגיאה -
ציטוט:

Parse error: syntax error, unexpected T_SL, expecting ',' or ';' in /home/goldsyst/domains/goldsystem.co.il/public_html/Panel/messege.php on line 9

4ior 26-04-07 22:03

תעדכן

Gold-System 26-04-07 22:05

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 '1`' at line 1

Eran-s 26-04-07 22:21

תנסה לרשום LIMIT 0,1 (כמובן בלי גרש)

Gold-System 26-04-07 22:24

כך?
PHP קוד:

$query mysql_query("SELECT * FROM `msg` LIMIT LIMIT 0,1") or die(mysql_error()); 


Eran-s 26-04-07 22:26

LIMIT אחד

Gold-System 26-04-07 22:27

אה, סליחה, לא שמתי לב ..
ולא עובד ..
PHP קוד:

<?
include "config.php"
if ( !isset(
$_POST['messege']) ) {
$query mysql_query("SELECT * FROM `msg` LIMIT 0,1") or die(mysql_error()); 
$con mysql_fetch_object($query);
$msg $con->Updote;
echo 
"
<html> 
<head>
<form action='messege.php' method='POST'> 
<div align='center'> 
<textarea name='messege'>$msg</textarea> 
<input type='hidden' value='1' name='xds' />
<input type='submit' value='עדכן תיבה'>
</form> 
</html>
"
;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE `msg` SET Updote = '$update'") or die(mysql_error());
}
?>


Eran-s 26-04-07 22:28

והשגיאה היא?

Gold-System 26-04-07 22:31

שגיאה - אין.
פשוט לא שומר את הנתונים בתיבה.

חיים 26-04-07 22:35

אתה בטוח ששינית במסד עצמו את השדה update ל-updote?

Gold-System 26-04-07 22:41

1000&#37;!
Updote לא updote

BlueNosE 26-04-07 22:44

PHP קוד:

<?
error_reporting 
(E_ALL);
include 
"config.php"
if ( !isset(
$_POST['messege']) ) {
$query mysql_query("SELECT * FROM msg LIMIT 0,1"); 
$con mysql_fetch_array($query);
$msg $con['Updote'];
echo 
"
<html> 
<head>
<form action='messege.php' method='POST'> 
<div align='center'> 
<textarea name='messege'>$msg</textarea> 
<input type='hidden' value='1' name='xds' />
<input type='submit' value='עדכן תיבה'>
</form> 
</html>
"
;
}

else {
$update $_POST['messege'];
mysql_query("UPDATE msg SET Updote = '{$update}'");
}
?>


Gold-System 26-04-07 22:47

קבל מה הבעיה, בלונוס -
http://goldsystem.co.il/Panel/messege.php

Eran-s 26-04-07 22:50

בקובץ CONFIG עשית DEFINE?

Gold-System 26-04-07 22:53

PHP קוד:

<?Php 
      mysql_connect
('localhost',ftft_msg,'******'); 
      
mysql_select_db("ftft_msg"); 
?>


Eran-s 26-04-07 23:17

לא שמת את שם המשתמש במרכאות

Gold-System 26-04-07 23:19

אוקיי, תיקנתי,
עדיין - לא שומר את הנתונים בתיבה.

Eran-s 26-04-07 23:30

תשים or die(mysql_error()) לשאילתת עדכון

Tomer 26-04-07 23:31

מתחיל להמאס לי,

PHP קוד:

<?php
ob_start
();
require_once(
"config.php");

if (!
$_POST) {

  
$sql mysql_query("SELECT `Updote` FROM `msg`") or die(mysql_error());
  
$r mysql_fetch_array($sql);
  
$msg $r['Updote'];

  echo <<<HTML
    <html> 
    <head>
    <form action='message.php' method='POST'> 
    <div align='center'> 
    <textarea name='messege'>
{$msg}</textarea> 
    <input type='submit' value='עדכן תיבה'>
    </form> 
    </html>
  HTML;
  
} else {

  $message = mysql_escape_string($_POST
['message']);
  
  $sql = mysql_query("UPDATE `msg` SET `Updote`='$message'") or die(mysql_error());
header("Location: message.php");

}
?>

תנסה את זה, רשמתי את זה עכשיו.


כל הזמנים הם GMT +2. הזמן כעת הוא 07:03.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ