Jump to content

Its expecting a ;


futurewii

Recommended Posts

Hey, I get this message..

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /mounted-storage/home36c/sub005/sc28991-YIVP/futurewii.com/pages/videos/view.php on line 10

 

With this script..

 

<div id="content"><br />
<br />
<?php

include "includes/conn.php";

$result = mysql_query("SELECT * FROM videos WHERE id = '".$_GET['id']."'")  
or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {
echo "<h2><span lang="en-gb">$row['title']</span></h2>";
	echo "<br />";
echo $row['script'];
	echo "<br />";
echo "<h7>$row['download']</h7>";
	echo "<br />";
	echo "<br />";
echo "<p><span lang="en-gb">$row['description']</span></p>";
echo "<br />";
   echo "<br />";
   echo "<br />";
echo "<br />";
   echo "<br />";
   echo "<br />";

$page_id = "$row['id']"; // for example
include("comments/comments_show.php");
include("comments/comments_form.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/
Share on other sites

Wow.  So many people code so sloppily these days.  When using arrays, the keys should be enclosed in ' ' or " " (for variable keys).  Then, when echo'd in a string, they must be enclosed in { }.

 

echo "{$row['title']}";

 

As an example.

 

The only reason that it works the way you have it is because PHP doesn't WANT to through errors at you, so it tries to "fix" it.  First, it looks for a constant named title, and if it doesn't find one, it ASSUMES you wanted 'title'.  You should really clean that up.

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572754
Share on other sites

Just because there isn't a <h7> tag defined in the standards, doesn't mean you can't use it and define the style via CSS. See:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
<style type="text/css" media="screen">
h7 {
	color: red;
	font-size: 150%;
}
</style>
</head>

<body>
<h7>This is a h7 area</h7>


</body>
</html>

 

True, it won't validate, but it does work (at least in Firefox3).

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572855
Share on other sites

Thanks  ;D

 

Just one more thing and i'm finished bugging you for tonight  :-[

 

<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php

include "includes/conn.php";

$query_count = "SELECT * FROM videos WHERE console='wii'"; 

		print "<p><tr><a href='?page=video&id=".$row['id']."'>".$row['title'] . "</a></tr>";
		print "<td>".$row['type']."</td>";
		print "</tr>";
		print "</tr>";
		print "</table>";

	 ?>

 

I'm wanting the table to only show entries which have their 'CONSOLE' value as 'wii' but nothing shows up in the table  ??? any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572863
Share on other sites

You need to fetch the results from the query:

<?php
$query_count = "SELECT * FROM videos WHERE console='wii'"; 
$row = mysql_fetch_assoc($query_count));
print "<p><tr><a href='?page=video&id=".$row['id']."'>".$row['title'] . "</a></tr>";
print "<td>".$row['type']."</td>";
print "</tr>";
print "</tr>";
print "</table>";
?>

 

Ken

 

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572866
Share on other sites

Hey, Thanks a lot for your help. The entry is called wii not 'wii' :P and when I try your code Ken i get this error..

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /mounted-storage/home36c/sub005/sc28991-YIVP/futurewii.com/pages/videos/index.php on line 15

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572870
Share on other sites

Sorry, forgot to put the query in:

<?php
$query_count = "SELECT * FROM videos WHERE console='wii'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs);
print "<p><tr><a href='?page=video&id=".$row['id']."'>".$row['title'] . "</a></tr>";
print "<td>".$row['type']."</td>";
print "</tr>";
print "</tr>";
print "</table>";
?>

 

You need to enclose strings in single quotes for mysql.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572872
Share on other sites

Now I get this  ???

 

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /mounted-storage/home36c/sub005/sc28991-YIVP/futurewii.com/pages/videos/index.php on line 15

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /mounted-storage/home36c/sub005/sc28991-YIVP/futurewii.com/pages/videos/index.php on line 15

Problem with the query: SELECT * FROM videos WHERE console=wii

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

 

Im really sorry for the constant questions, everyone here is extremely helpful and its the only way i'll learn  :P

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572873
Share on other sites

Oh dear.. :(

 

All my other databases seem to still be active though, but as long as there's no scripting errors :) By the way can i just check that

 

WHERE console='wii'";

 

Is the correct phrase to make the table only show fields which have wii as the entry under 'console'?

 

Thanks muchly  ;D

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-572876
Share on other sites

<div id="content">
<h2><span lang="en-gb">Video Database..</span></h2>

		<br /><br />
<h2>Nintendo Wii</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='wii'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>

<br /><br />
<h2>Gamecube</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='ngc'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>
<br /><br />
<h2>Virtual Console</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='vcg'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>
<br /><br />
<h2>Other Videos</h2>
<br />
<table width="400">
<tr style='font-size:12px;' bgcolor="#c0c0c0">
	<th>Game Title</th>
	<th>Video Type</th>
<?php
include "includes/conn.php";
$query_count = "SELECT * FROM videos WHERE console='oth'"; 
$rs = mysql_query($query_count) or die("Problem with the query: $query_count<br>" . mysql_error());
$row = mysql_fetch_assoc($rs); {
		print "<tr style='font-size:12px;'>";
		print "<td><a href='?page=videos/view&id=".$row['id']."'>";
		echo $row['title'];
		print "</a></td>";
		print"<td>".$row['type']."</td>";
		print "</tr>";

	}

?>

<br />

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/111582-its-expecting-a/#findComment-573179
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.